notes on compiling spring with mingw32 on win
Moderator: Moderators
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
notes on compiling spring with mingw32 on win
edit: Decided to use this to keep track of what has to be done to compile spring on win using mingw32. I'll update the wiki once (if) I'm done...
So, I tried to compile spring on win7 with mingw and came up against the following problem.
The linker tries to use windres. In order to have even got this far one has to be using dwarf2 with mingw32, but then windres looks for gcc and not for gcc-dw2.
Possibly this can be helped by passing some arguments to windres, but cmake doesn't like that because it involves whitespaces and only one of the two instances within the cmake config that related to windres offers a separate field in which to pass arguments. (Also whenever cmake finds an error in its config it forgets _all_ settings after the point at which the error occurs which is _completely_ stupid and wastes _so_ much time finding pthreads and freetype _over_ and _over_ again...)
Strangely, I found someone from cygwin claiming that windres actually depends on cygwin (wtf): http://www.cygwin.com/ml/cygwin/2011-05/msg00123.html. But either way it looks as though compiling spring on win needs both dwarf2 and non-dwarf2, which is a bit wtf... (edit: see below for a workaround)
[Sidenote: There is an error on the wiki in that it tells you to get the vclibs version of freetype for mingw32; in fact (I think) you only want the vclibs one when using visual studio and for mingw you want the freetype from within mingwlib. Someone who knows enough to be sure should correct this.]
So, I tried to compile spring on win7 with mingw and came up against the following problem.
The linker tries to use windres. In order to have even got this far one has to be using dwarf2 with mingw32, but then windres looks for gcc and not for gcc-dw2.
Possibly this can be helped by passing some arguments to windres, but cmake doesn't like that because it involves whitespaces and only one of the two instances within the cmake config that related to windres offers a separate field in which to pass arguments. (Also whenever cmake finds an error in its config it forgets _all_ settings after the point at which the error occurs which is _completely_ stupid and wastes _so_ much time finding pthreads and freetype _over_ and _over_ again...)
Strangely, I found someone from cygwin claiming that windres actually depends on cygwin (wtf): http://www.cygwin.com/ml/cygwin/2011-05/msg00123.html. But either way it looks as though compiling spring on win needs both dwarf2 and non-dwarf2, which is a bit wtf... (edit: see below for a workaround)
[Sidenote: There is an error on the wiki in that it tells you to get the vclibs version of freetype for mingw32; in fact (I think) you only want the vclibs one when using visual studio and for mingw you want the freetype from within mingwlib. Someone who knows enough to be sure should correct this.]
Last edited by Silentwings on 22 Dec 2013, 02:20, edited 4 times in total.
Re: mingw32 on win has an issue with windres/gcc-dw2
wiki already says soSilentwings wrote:In order to have even got this far one has to be using dwarf2 with mingw32
what?Silentwings wrote:in fact (I think) you only want this when visual studio and for mingw you want the freetype from within mingwlib. Someone who knows enough to be sure should correct this.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: mingw32 on win has an issue with windres/gcc-dw2
Yes, that's why I did it!wiki already says so
Using the freetype lib from within vclibs gave me the following errors:what?
Code: Select all
Linking CXX executable ..\..\..\spring.exe
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
Warning: .drectve `/DEFAULTLIB:"MSVCRT" ' unrecognized
C:\Spring_engine\source\trunk\vclibs\freetype\lib\freetype.lib(./../../../objs/release/ftbase.obj):(.text[_FT_Set_Char_Size]+0x7):
undefined reference to `__security_cookie'
C:\Spring_engine\source\trunk\vclibs\freetype\lib\freetype.lib(./../../../objs/release/ftbase.obj):(.text[_FT_Set_Char_Size]+0x84)
: undefined reference to `@__security_check_cookie@4'
c:/progra~2/tdm-gc~1/bin/../lib/gcc/mingw32/4.7.2/../../../../mingw32/bin/ld.exe: C:\Spring_engine\source\trunk\vclibs\freetype\li
b\freetype.lib(./../../../objs/release/ftbase.obj): bad reloc address 0x84 in section `.text[_FT_Set_Char_Size]'
collect2.exe: error: ld returned 1 exit status
rts\builds\legacy\CMakeFiles\engine-legacy.dir\build.make:12934: recipe for target 'spring.exe' failed
mingw32-make[3]: *** [spring.exe] Error 1
CMakeFiles\Makefile2:2787: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/all' failed
mingw32-make[2]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/all] Error 2
CMakeFiles\Makefile2:2799: recipe for target 'rts/builds/legacy/CMakeFiles/engine-legacy.dir/rule' failed
mingw32-make[1]: *** [rts/builds/legacy/CMakeFiles/engine-legacy.dir/rule] Error 2
Makefile:835: recipe for target 'engine-legacy' failed
mingw32-make: *** [engine-legacy] Error 2
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: mingw32 on win has an issue with windres/gcc-dw2
It seems you can pass a
to windres and that will avoid the issue; this should be set as CMAKE_RC_FLAGS.
Now I progressed onto "undefined reference to" std::.......... stuff errors from the linker that I'll look at myself for a while, a quick google search suggests I'm not alone...
Code: Select all
--preprocessor="gcc-dw2 -E -xc -DRC_INVOKED"
Now I progressed onto "undefined reference to" std::.......... stuff errors from the linker that I'll look at myself for a while, a quick google search suggests I'm not alone...
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: notes on compiling spring with mingw32 on win
cmake config:
g++-dw2 needs to be the c++ compiler (and gcc-dw2 the c compiler; but not c++ compiler) in cmake, else the linker won't be able to find the standard libs (http://stackoverflow.com/questions/8904 ... rd-library)
then pthreads (from its own archive) and freetype (from mingwlib) have to be added, then the flag from the post above.
g++-dw2 needs to be the c++ compiler (and gcc-dw2 the c compiler; but not c++ compiler) in cmake, else the linker won't be able to find the standard libs (http://stackoverflow.com/questions/8904 ... rd-library)
then pthreads (from its own archive) and freetype (from mingwlib) have to be added, then the flag from the post above.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: notes on compiling spring with mingw32 on win
Next issue is precisely these errors http://stackoverflow.com/questions/7751 ... nality-sj0.
Problem (I think) is that mingwlibs were compiled without dw2 and consequently can give errors when linked to the dw2 compiled stuff.
Seems this was an issue in the past too: http://springrts.com/phpbb/viewtopic.php?f=12&t=23096
Problem (I think) is that mingwlibs were compiled without dw2 and consequently can give errors when linked to the dw2 compiled stuff.
Seems this was an issue in the past too: http://springrts.com/phpbb/viewtopic.php?f=12&t=23096
Re: notes on compiling spring with mingw32 on win
http://springrts.com/wiki/Building_Spri ... e_Problems
-> I assume you did something wrong with your mingw install, there should be no gcc-dw2.exe
(didn't tried to setup a windows mingw environment for a while, so I may missed a TDM change)
-> and no sjlj libs in mingwlibs don't cause a linker problem, if at all at runtime exception handling may break when it happens inside one of those.
-> I assume you did something wrong with your mingw install, there should be no gcc-dw2.exe
(didn't tried to setup a windows mingw environment for a while, so I may missed a TDM change)
-> and no sjlj libs in mingwlibs don't cause a linker problem, if at all at runtime exception handling may break when it happens inside one of those.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: notes on compiling spring with mingw32 on win
I had a previous gcc and when I installed TDM I originally I went for the 'latest' (instead of 'stable') and choose the dw2 version; in that case TDM renames ~everything with -dw2 on the end. It's not abig deal afaik, you just have to tell cmake where to look for stuff. But it was annoying to keep telling this to cmake so in fact I've removed the lot and done a plain TDM install; no more -dw2's and it also solves the windres issue without having to pass anything.
I do still get those same linker errors with boost/sjlj; precisely the errors mentioned in the stack overflow link, which are also part of the errors that someone else was getting on that old spring forums link. http://pastebin.com/BEypCCQV.
The wiki (right where you linked too) mentions these linker errors explicitly and says that to fix I should uninstall TDM and reinstall making certain I get dw2 (which of course I've already tried - it made no difference). Maybe the explanation given on stack overflow - that some parts of boost need to be built with dw2 before they can link to dw2 stuff - is correct?
I do still get those same linker errors with boost/sjlj; precisely the errors mentioned in the stack overflow link, which are also part of the errors that someone else was getting on that old spring forums link. http://pastebin.com/BEypCCQV.
The wiki (right where you linked too) mentions these linker errors explicitly and says that to fix I should uninstall TDM and reinstall making certain I get dw2 (which of course I've already tried - it made no difference). Maybe the explanation given on stack overflow - that some parts of boost need to be built with dw2 before they can link to dw2 stuff - is correct?
Re: notes on compiling spring with mingw32 on win
Incorrect we build boost ourself for mingwlibs with dwarf2, and our cross-compile buildbot links fine (again dwarf2).
When you get sjlj linker errors something went wrong in your environment.
When you get sjlj linker errors something went wrong in your environment.
Last edited by jK on 23 Dec 2013, 00:20, edited 2 times in total.
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: notes on compiling spring with mingw32 on win
Thanks, thats very handy to know... I'll keep working on it.
Re: notes on compiling spring with mingw32 on win
hmmm seems abma did a boost build on his buildclient and it was missing dw2 ...
will issue a rebuild on mine
will issue a rebuild on mine
Re: notes on compiling spring with mingw32 on win
k made a build w/o sjlj: https://github.com/spring/mingwlibs/com ... f063a28b2d
but it broke mingw64 buildbot, so I reverted them afterwards.
For you they should work so just checkout that rev (was too lazy to make a branch ^^).
but it broke mingw64 buildbot, so I reverted them afterwards.
For you they should work so just checkout that rev (was too lazy to make a branch ^^).
- Silentwings
- Posts: 3720
- Joined: 25 Oct 2008, 00:23
Re: notes on compiling spring with mingw32 on win
Yes, it worked with those! Thank you.