[Solved] Cross compiling Irrlicht for Win32 on Linux

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Elmaron
Posts: 27
Joined: Sat Jan 10, 2009 7:22 pm

[Solved] Cross compiling Irrlicht for Win32 on Linux

Post by Elmaron »

Hi. I recently tried to cross compile the Irrlicht engine on Linux for the Windows platform (I have no direct access to any windows machine so I am in great need for this). So I opened up the Makefile and tried to add what seems to be necessary to cross compile (replacing the old similar lines if they were present):

Code: Select all

CC = i486-mingw32-gcc
CXX = i486-mingw32-c++
CXXCPP = i486-mingw32-c++ -E
AS = i486-mingw32-as
AR = i486-mingw32-ar
I also removed the #ifdef NDEBUG condition so I always get a release build (poor me doesn't know how to tell make to define some value and that was therefore the faster solution :roll:) and added -D__GNUWIN32__ as mingw didn't seem to define this and I ran into crtdb.h - or how that MSVC debugging solution is called - issues, because the compilation process wanted that file.

So it kinda went smoothly through (this is the very short description of a lot of hassle to get all the Makefile lines above together and finally arrive at this point :?) and seemed to compile fine:

http://pastebin.com/m4c9be4dd (this was simply too long to include it here)

But then I attempted to link my application to it/compile my application with it and ran into the following error:

Code: Select all

bash-4.0$ make wcomp
cd src && i486-mingw32-c++ game.cpp -o ../GAME.EXE -L../irrlichtsvn_w/lib/Linux -mwindows -I../irrlichtsvn_w/include -I/usr/X11R6/include -I../../bullet-2.74/src/ ../../bulletw/src/.libs/libbulletdynamics.a ../../bulletw/src/.libs/libbulletmath.a ../../bulletw/src/.libs/libbulletcollision.a -lIrrlicht -DWIN
/tmp/cc6wpc5m.o:game.cpp:(.text+0xa5a3): undefined reference to `__imp__createDeviceEx'
collect2: ld returned 1 exit status
make: *** [wcomp] Error 1
bash-4.0$
I already tried around a lot with guys in the chat, making sure irrlicht headers & source code versions are the same (this is Irrlicht 1.6 SVN 2586) and checked paths twice, the lib is truly located at ../irrlichtsvn_w/lib/Linux:

Code: Select all

bash-4.0$ ls ../irrlichtsvn_w/lib/Linux/
libIrrlicht.a
Also, nm -D on libIrrlicht.a gives strange output. I was told that this wouldn't help this case at all :P but meh, just in case it gives someone _any_ clue that could help solving the problem:

Code: Select all

nm: CLMTSMeshFileLoader.o: File format not recognized
nm: CMY3DMeshFileLoader.o: File format not recognized

...long continuing list
I really hope someone coming across this post can help.

PS: Did you ever check out the great cross compilation that comes with the bullet physics lib? You can simply do ./configure --host=i486-mingw32 and then do the usual make and it just runs smoothly as you'd be doing a normal compile (apart from some missing glut headers and stuff, but that's much easier and straightforward to fix as my issues with irrlicht now that leave me completely clueless!).

It would be really nice if irrlicht's Makefile would also develop some similar assistance for cross compiling people like me :) (just an idea)
Last edited by Elmaron on Wed Aug 12, 2009 6:09 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You're not supposed to change the Makefile. Just use command line environment variables like this:
CXX=i486-mingw32-c++ CC=i486-mingw32-gcc make all_win32

This line will provide all the necessary setup to cross-compile Irrlicht. The same holds for the example makefiles. Runs out-of-the box for me.
Elmaron
Posts: 27
Joined: Sat Jan 10, 2009 7:22 pm

Post by Elmaron »

I now compiled it with the default Makefile again, using this line:

Code: Select all

CXX=i486-mingw32-c++ CC=i486-mingw32-gcc make staticlib_win32
When attempting to link the result to my app, I get again:

Code: Select all

cd src && i486-mingw32-c++ game.cpp -o ../GAME.EXE -L../irrlichtsvn_w/lib/Linux -mwindows -I../irrlichtsvn_w/include -I/usr/X11R6/include -I../../bullet-2.74/src/ ../../bulletw/src/.libs/libbulletdynamics.a ../../bulletw/src/.libs/libbulletmath.a ../../bulletw/src/.libs/libbulletcollision.a -lIrrlicht -DWIN
/tmp/ccnfMhRi.o:game.cpp:(.text+0xa5a3): undefined reference to `__imp__createDeviceEx'
collect2: ld returned 1 exit status
make: *** [wcomp] Error 1
bash-4.0$
:cry: :cry: :cry: :cry: :cry: :cry: :cry:

Edit:
Also tried your original line now:

Code: Select all

CXX=i486-mingw32-c++ CC=i486-mingw32-gcc make all_win32
Same result. :x
Elmaron
Posts: 27
Joined: Sat Jan 10, 2009 7:22 pm

Post by Elmaron »

I feel dumb now... as you can see with the compiler command line I was simply still taking the lib out of lib/Linux where it was located with my modified Makefile. Ofc it still didn't work then :?
So thanks a lot for your hint hybridOL, it works now :D Yay!
Post Reply