[Solved/Devs must read] win32gcc projects,mkfiles are broken

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.
Post Reply
Isomorphix
Posts: 16
Joined: Fri Aug 16, 2013 5:08 pm

[Solved/Devs must read] win32gcc projects,mkfiles are broken

Post by Isomorphix »

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 ... -

In the makefile of each "example" project.
  • Change CPPFLAGS from

    Code: Select all

    CPPFLAGS = -I../../include -I/usr/X11R6/include
    to

    Code: Select all

    CPPFLAGS = -I../../include
    and add this line below #target specific settings

    Code: Select all

    all_linux: CPPFLAGS += -I/usr/X11R6/include
  • Change all_win32: LDFLAGS from

    Code: Select all

    all_win32: LDFLAGS = -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm
    to

    Code: Select all

    all_win32: LDFLAGS = -static-libgcc -static-libstdc++ -L../../lib/Win32-gcc -lIrrlicht -lopengl32 -lm -lwinmm -lgdi32
    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.

    Code: Select all

    all_win32: CPPFLAGS += -D__GNUWIN32__ -D_WIN32 -DWIN32 -D_WINDOWS -D_IRR_STATIC_LIB_ 
    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.





In Irrlicht-gcc.cbp
  • under each -static target change

    Code: Select all

    <Option object_output="..\obj\win32-gcc-...-shared"/>
    to

    Code: Select all

    <Option object_output="..\obj\win32-gcc-...-static"/>
Last edited by Isomorphix on Sun Aug 18, 2013 8:44 am, edited 15 times in total.
CuteAlien
Admin
Posts: 9693
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Irrlicht's win32-gcc projects,makefiles seem to be broke

Post by CuteAlien »

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.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Isomorphix
Posts: 16
Joined: Fri Aug 16, 2013 5:08 pm

Re: Irrlicht's win32-gcc projects,makefiles seem to be broke

Post by Isomorphix »

_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. :!:
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: [Solved/Devs must read] win32gcc projects,mkfiles are br

Post by hendu »

And cause a ton of new issues...
Isomorphix
Posts: 16
Joined: Fri Aug 16, 2013 5:08 pm

Re: [Solved/Devs must read] win32gcc projects,mkfiles are br

Post by Isomorphix »

hendu wrote:And cause a ton of new issues...
If you say so :D .

Well, I thought cmake would be a good idea since alot of projects that support many platforms have switched to it. Take ACE for example.
CuteAlien
Admin
Posts: 9693
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [Solved/Devs must read] win32gcc projects,mkfiles are br

Post by CuteAlien »

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...).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Isomorphix
Posts: 16
Joined: Fri Aug 16, 2013 5:08 pm

Re: [Solved/Devs must read] win32gcc projects,mkfiles are br

Post by Isomorphix »

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?

Thanks in advance!
CuteAlien
Admin
Posts: 9693
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: [Solved/Devs must read] win32gcc projects,mkfiles are br

Post by CuteAlien »

The patchtracker is probably the best place: http://sourceforge.net/p/irrlicht/patch ... rce=navbar
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply