Error when Compiling with g++ through Command Line

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Error when Compiling with g++ through Command Line

Post by Helderash »

Hey folks!

For a number of reasons I've had to switch from using my usual VS8 compiler to a command line g++ compiler. I am however receiving one error when compiling code that previously compiles fine with VS8.

C:/DOCUME~1/JAMESD~1/LOCALS~1/Temp/ccofbaaa.o(.text+0x11f7):Application_Main.cpp: undefined reference to `_imp___ZN3irr12createDeviceENS_5video13E_DRIVER_TYPEERKNS_4core11dimension2dIiEEjbbbPNS_14IEventReceiverEPKc'

Am I perhaps missing a required file link? My compile command is as follows:

g++ Application_Main.cpp -I../irrlicht-1.3/include/ -I../irrlicht-1.3/source/Irrlicht/ -I/C/Program\ Files\Microsoft\ Platform\ SDK\ for\ Windows\ Server\ 2003\ R2/Include/

Thankyou for all the help, it is very much appreciated!
thephoenix
Posts: 19
Joined: Wed Jan 25, 2006 7:44 pm

Post by thephoenix »

add "-lIrrlicht" and make sure that g++ finds the Irrlicht.a (The dll should work as well, but afair only with other options)
Also maybe code from the PSDK doesn't work with g++ as well...
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

Thanks for the help phoneix! Changing the compile command to:

g++ Application_Main.cpp -I../irrlicht-1.3/include/ -I. -I../irrlicht-1.3/source/Irrlicht/ -I/C/Program\ Files\Microsoft\ Platform\ SDK\ for\ Windows\ Server\ 2003\ R2/Include/ -l../irrlicht-1.3/lib/Win32-gcc/libIrrlicht.a

produces the following error instead:

C:\MinGW\bin\..\lib\gcc-lib\mingw32\3.2.3\..\..\..\..\mingw32\bin\ld.exe: cannot find -l../irrlicht-1.3/lib/Win32-gcc/libIrrlicht.a

I've double checked and that file definately exists in that folder, so I'm very confused about what could be going wrong now.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The correct command line is: -L/path/to/library/without/filename -lfilename
So you remove the libIrrlicht.a from the first option, and you remove the lib and .a in the second option. You will also have to add several win32 libraries. Have a look at the makefile of Irrlicht. If you have a make available you can call 'make sharedlib_win32' to create the .dll automatically.
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

That worked perfectly hybrid, thankyou very much. The code now compiles into an exe file correctly.

I also compiled Irrlicht using the Irrlicht makefile, and added the Win32-gcc Irrlicht.dll to my project folder. However, when running my exe file I get the following in the DOS Prompt pop-up:

DIRECT3D9 Driver was not compiled into this dll. Try another one.

I assume it's talking about the Irrlicht driver, but I could be wrong. Any idea how to solve this issue?

Thankyou once more for all your help!
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You have to define IRR_COMPILE_WITH_DX9_DEV_PACK and of course have all include paths for the directX SDK set up. Also add the libraries to link against. Please note that only the d3d9 library can be easily converted for use with mingw, the d3d8 usually refuses to work. In that case you can grab an older one from the forum (search in the FAQ forum) or disable DirectX8 in IrrCompileConfig.h
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

Sadly, I don't seem to be having much luck. I added the following to IrrCompileConfig.h:

#define _IRR_COMPILE_WITH_DX9_DEV_PACK_

I've also changed the Makefile so the compile line reads:

$(CXX) $(CPPFLAGS) $(CXXFLAGS) -shared -o $@ $^ $(LDFLAGS) -Wl,--out-implib,../../lib/Win32-gcc/$(STATIC_LIB) -L/C/DX90SDK/Lib -ld3dx9

which is just linking in the necessary d3dx9.lib file. The same problem is resulting, so I'm guessing I've either placed the #define in the incorrect place, or not linked things correctly (or not linked all the necessary dx9 libraries).

The Makefile is however building a different version of the Irrlicht.dll file, as the 2.91Mb file I originally had has become 14Mb.
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The Makefile creates a debug release by default. Use 'make NDEBUG=1' to get an optimized version.
Did you rebuild the complete library? There are several places which are disabled when compiling without DirectX support. Also b sure that you use the correct library when executing later on.
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

To be honest I'm unsure whether I'm building the full library or not (I'm very new to command line compilation). My current command line instruction is:

make -f Makefile win32

I am currently using the most up-to-date Irrlicht.dll in each case when running the exe file. I did just try moving the #define _IRR_COMPILE_WITH_DIRECT3D_9_ outside the #if (defined(_IRR_WINDOWS_) || defined(_XBOX)) && \ to ensure it was being carried out. This has created numerous errors with CD3D9Driver.cpp of the type:

CD3D9Driver.cpp:2088: parse error before `;' token
CD3D9Driver.cpp:2089: `D3DFMT_A8R8G8B8' undeclared (first use this function)
CD3D9Driver.cpp:2089: `D3DPOOL_SCRATCH' undeclared (first use this function)
CD3D9Driver.cpp:2089: `lpSurface' undeclared (first use this function)
CD3D9Driver.cpp:2114: `D3DLOCKED_RECT' undeclared (first use this function

I'm guessing this is because I haven't correctly included the DX9 include files in the makefile. I'll do this and see what happens.
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

Okay, including the DX9 include folder results in the following:

In file included from c:/DX90SDK/Include/d3d9.h:199,
from CD3D9Driver.h:18,
from CD3D9Driver.cpp:9:
c:/DX90SDK/Include/d3d9types.h:25: warning: ignoring #pragma warning
c:/DX90SDK/Include/d3d9types.h:1789: warning: ignoring #pragma warning
In file included from c:/DX90SDK/Include/d3dx9.h:45,
from c:/DX90SDK/Include/d3dx9shader.h:10,
from CD3D9ShaderMaterialRenderer.h:13,
from CD3D9Driver.cpp:18:
c:/DX90SDK/Include/d3dx9math.h:19: warning: ignoring #pragma warning
In file included from c:/DX90SDK/Include/d3dx9.h:45,
from c:/DX90SDK/Include/d3dx9shader.h:10,
from CD3D9ShaderMaterialRenderer.h:13,
from CD3D9Driver.cpp:18:
c:/DX90SDK/Include/d3dx9math.h:1755: warning: ignoring #pragma warning
In file included from c:/DX90SDK/Include/d3dx9.h:46,
from c:/DX90SDK/Include/d3dx9shader.h:10,
from CD3D9ShaderMaterialRenderer.h:13,
from CD3D9Driver.cpp:18:
c:/DX90SDK/Include/d3dx9core.h:636:1: warning: multi-line comment
In file included from c:/DX90SDK/Include/d3dx9mesh.h:15,
from c:/DX90SDK/Include/d3dx9.h:47,
from c:/DX90SDK/Include/d3dx9shader.h:10,
from CD3D9ShaderMaterialRenderer.h:13,
from CD3D9Driver.cpp:18:
c:/DX90SDK/Include/dxfile.h:240: stray '\32' in program
In file included from c:/DX90SDK/Include/d3dx9mesh.h:15,
from c:/DX90SDK/Include/d3dx9.h:47,
from c:/DX90SDK/Include/d3dx9shader.h:10,
from CD3D9ShaderMaterialRenderer.h:13,
from CD3D9Driver.cpp:18:
c:/DX90SDK/Include/dxfile.h:240:2: warning: no newline at end of file
CD3D9Driver.cpp: In member function `virtual void
irr::video::CD3D9Driver::drawVertexPrimitiveList(const void*, unsigned int,
const u16*, unsigned int, irr::video::E_VERTEX_TYPE,
irr::scene::E_PRIMITIVE_TYPE)':
CD3D9Driver.cpp:868: warning: enumeration value `EPT_QUAD_STRIP' not handled in
switch
CD3D9Driver.cpp:868: warning: enumeration value `EPT_QUADS' not handled in
switch
CD3D9Driver.cpp:868: warning: enumeration value `EPT_POLYGON' not handled in
switch
make: *** [CD3D9Driver.o] Error 1

Thankyou for the help so far hybrid, I do really appreciate it!
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

The original problem with the define was that it has no underscores at the ends.
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

Aha okay, altering that has meant the #define _IRR_COMPILE_WITH_DIRECT3D_9_ can remain in it's original spot.

I am still getting the same errors as previously though, to do with the CD3D9Driver.cpp code. I'll have to have another crack at it in the morning. :)
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Oh, I did not see the Error at the end, where does it come from? I only saw warnings!?
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

I must admit that's confusing me somewhat too. I output the entire build log to file, and searching through it I can't see anything but warnings.

Would there possibly be any way to build the Win32-gcc Irrlicht.dll through Visual Studio?
Helderash
Posts: 49
Joined: Sun Mar 25, 2007 8:41 pm

Post by Helderash »

c:/DX90SDK/Include/dxfile.h:240: stray '\32' in program

Removing this from the dxfile.h allowed the compiler to jump past this point. It's now having trouble with the directx .lib files, but I guess I need to convert them to .a files with reimp first.
Post Reply