All of the steps below used the projectfiles/makefiles distributed with Irrlicht, no changes were made to them.
Building Irrlicht as a static library:
First of all, building Irrlicht using the command make win32 as stated in the Makefile is failing while compiling LzmaDec.c .
The Code::Blocks project used to build Irrlicht errorneously states that Win32 -static targets are built in win32-release/debug-shared.
Overall, building Irrlicht as Win32 Debug -static with Code::Blocks (not make) works producing a 50MB .a file.
Using Irrlicht statically:
Building hello world #1 with the command make static_win32 adds linux directories. It also fails to link libIrrlicht.a since the compiler complains about an undefined reference _imp__createDevice.
Code::Blocks also reports the undefined reference.
Am I doing something wrong?
Fixes:- the following list is still being populated ... -
NOTE #1: You might need to add -ld3dx9d for Direct3D support (9.0) depending wether you compiled Irrlicht with -DNO_IRR_COMPILE_WITH_DIRECT3D_9_ or -DIRR_COMPILE_WITH_DX9_DEV_PACK NOTE #2: When trying to use Irrlicht as a shared library you shouldn't include opengl32 winmm gdi32 and d3dx9d since Irrlicht automagically links itself to those.
Add this line below all_win32: LDFLAGS if it doesn't already exist and read NOTE #1.
NOTE #1: Remove -D_USRDLL and -D_MBCS these are microsofts-compiler-related, I don't believe they're of any use to gcc. NOTE #2: If you are compiling without joystick support make sure Irrlicht is compiled with -DNO_IRR_COMPILE_WITH_JOYSTICK_EVENTS_, you should also include that in the above flags. Also remove -lwinmm you won't need it unless you like joysticks.
Hm, have to check when I'm back on Windows. About the linking - you have to set the _IRR_STATIC_LIB_ define in your application and in Irrlicht. The Makefile set's it for Irrlicht (but not for your application), don't know about the c::b file right now - have to check that as well.
_IRR_STATIC_LIB_ wasn't defined in either the mkefile or the main file. I could fix Irrlicht's Makefiles for Windows, but I need to get the library working first before I touch anything else.
Irrlicht needs cmake desperately. It would fix most problems that occur because of poor project-file maintenance.
Thanks for the list. I'm again on Linux today, but yeah - the Makefiles of the project files have not been written with static lib in mind. Neither the c::b files. So far the examples are simply written in the expectation that the Library is compiled with dll on Windows (and static on Linux...).
You're welcome, right now, I'm fixing the win32 part of every makefile. I also noticed that the master makefile is bloated with .o object files. I will try to minify the code using make's built-in directory parsing tricks. I'm on vacation atm and therefore I can not touch the linux part of them.
Where should I post the modified makefiles / c::b projects when I'm done?