Problems with Boost when building on Windows

Problems with Boost when building on Windows

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Problems with Boost when building on Windows

Post by Rocko Bonaparte »

I'm trying to build the engine from the git stable source on Windows. For the record, I am running Windows 8. I have tried with both VS2010 and also with the mingw procedure. Either way, I run into problems with the Boost dependencies. I use Boost for my own stuff, so I do have some awareness of some of the shenanigans. Nonetheless, I wanted to try the forums to check on the build chain and make sure it isn't indeed something stupid. I could try to smash through those problems, only to run into something worse.

In VS2010, all the Boost libraries under vclibs are of the gd-mt variety. I believe that means they are built with debug symbols, and they are meant to link with the multithreaded Win32 runtime libraries. However, I got smacked in the middle of linkage when it tried to find sgd-mt varieties, which additionally imply static linkage. I'm not entirely sure how this all happens in Boost, but I've seen it in the past intervene in ways that make it want a different linkage than what I had specified, and I am suspecting it is what happened here. Anyways, vclibs isn't including the sgd libraries, so it fails out. I have my own 1.52 builds of Boost that I am tempted to try in place there.

Generally I prefer to follow online steps and see what the developers recommend before going off on a tangent, and I am assuming most of the developers are not using a Microsoft toolchain, so I tried the mingw route. After plenty of shenanigans with accidentally picking a TDM distribution over mingw-stable, it finally started to compile, only again to get beaten up over another Boost library problem.

In this case:

Code: Select all

C:\coding\spring\mingwlibs\lib\libboost_thread-mt.a(thread.o):thread.cpp:(.text+0x3fbf): undefined reference to `boost::chrono::system_clock::now()'
collect2.exe: error: ld returned 1 exit status
Generally this comes out of the dark when trying to use Boost.Thread; it needs Boost.Chrono for some odd thing. Now I see it in the mingwlibs, so somebody did think about that. For whatever reason, the toolchain isn't picking it up. I went grepping around in the cmake definitions and it never gets mentioned. I'm not good with cmake so I can't really be certain where I might try to go in and sneak this in. I can think of two ways to fix it: add Boost.Chrono sequentially after Boost.Thread apparently does the trick, or else getting the linker to seek inside the Boost dependencies directory when it can't find whatever it needs for whatever reason.

Personally I'm hoping for help on the VS2010 but I'm not that picky. I tried my best to follow the build directions on the development section of the web page, but early on it already required some divergence. For both creating vclibs and mingwlibs, it says to create that directory, go into it, then do a git pull. That ends up with vclibs\vclibs and mingwlibs\minglibs, respectively, which isn't what the toolchain expects. So it's possible I ran off and messed something else up in the process under good intentions.
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

I suppose I should mention to even get that far in the VS2010 build I had to beat the snot out of the project configuration to get out of some project variable shenanigans. A virgin build would give you this warning:

Code: Select all

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(990,5): warning MSB8012: TargetPath(C:\coding\spring\rts\build\vstudio10\Debug\rts.exe) does not match the Linker's OutputFile property value (C:\coding\spring\dist\spring.exe). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppBuild.targets(992,5): warning MSB8012: TargetName(rts) does not match the Linker's OutputFile property value (spring). This may cause your project to build incorrectly. To correct this, please make sure that $(OutDir), $(TargetName) and $(TargetExt) property values match the value specified in %(Link.OutputFile).
...and then it can't find any of the libraries. I guess it tries to find Freetype first, and it just stops there.

Update: ...and I was thwarted in trying to link in my own 1.52 Boost libraries in the vclibs path because I'm one of those wacky wild anarchists that like to try bleeding-edge technologies like 64-bit libraries. I know--that stuff's been around for only a decade. Sorry about that. If anybody thinks it'll matter I'll try to get Boost off on a 32-bit building tangent, but sometimes Boost.Build only does what you expect if you sacrifice a goat in front of it.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Problems with Boost when building on Windows

Post by abma »

did you use the project file included in the spring repository or do you use cmake to generate the project file?

which version of spring do you try to compile? the release branch contains that should create a working VS project file with cmake...
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: Problems with Boost when building on Windows

Post by jK »

tl'dr
but I fixed mingwlibs were missing chrono
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

abma wrote:did you use the project file included in the spring repository or do you use cmake to generate the project file?

which version of spring do you try to compile? the release branch contains that should create a working VS project file with cmake...
I tried the VS2010 project when I tried to do the Visual Studio compilation, but when I tried the mingw compilation, I generated the project file from the cmake-gui. In that case, for the source folder, I pointed it at the root of the repository (C:\coding\spring in my case).
jK wrote: tl'dr
but I fixed mingwlibs were missing chrono
Both the mingwlibs and vclibs I was able to get did include chrono, but I didn't find either project explicitly referencing it. In the case of Visual Studio, it was moot since it wanted to use the statically-linked Boost libraries. In the mingw case, I couldn't find a single file actually referring to it explicitly.

I believe some of this is being triggered when the compiler starts crunching on the Boost headers. I can't remember what the Boost people call it, but their headers are basically sentient, angry creatures that decide at a whim they'll start using static linkage, or that they need to drag in stuff like Boost.Chrono. I don't know how it can dynamically override the build settings during the build. I ran into it trying to do some Boost.Python stuff, and I think it's the same kind of thing here.



In the short term, I wanted to see what making mods was like with Spring, so I look like I'm in the clear with a pre-built installation.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Problems with Boost when building on Windows

Post by abma »

which version of spring do you try to compile? the release branch contains that should create a working VS project file with cmake...
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Problems with Boost when building on Windows

Post by abma »

Rocko Bonaparte wrote:In the short term, I wanted to see what making mods was like with Spring, so I look like I'm in the clear with a pre-built installation.
you don't need to compile spring to make a game...
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

Yes it should be clear I have figured that part out. I had started to dabble in that without getting the whole source to compile, but I wanted to have it on ready so I could try more dramatically altering things.

You have to excuse me about generating a Visual Studio project with cmake. I don't normally use cmake so I don't know what it can necessarily do. What you have double quoted there must imply it can generate a new Visual Studio solution file. I think I need a little hand holding on that point then if you're willing to help. I have cmake-gui open, but I'm not sure how to have it generate a Visual Studio project from there. What do I do to have it generate a Visual Studio project.

Also, is that the normal way with which a Visual Studio project is made?
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Problems with Boost when building on Windows

Post by abma »

you still didn't answer my questions. you ignore me, i ignore you... (which version of spring do you try to compile?)

what is your final goal?
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

abma wrote:you still didn't answer my questions. you ignore me, i ignore you... (which version of spring do you try to compile?)

what is your final goal?
I don't really know how to answer which version I built, as it never built enough for me to report a version string. All I can find is VersionGenerated.h that just has the generic "@SPRING_VERSION_ENGINE@" stubs. So I can only report back with what I could find out from source control.

I went for the stable release here:
http://springrts.com/wiki/Building_Spring_on_Windows

Specifically I cloned with:
git clone -b master git://github.com/spring/spring.git
The last commit being
Merge: 6e0aa6f c44a35c
Author: jK <-jk->
Date: Thu Aug 30 22:56:41 2012 +0200

Merge branch 'post_release'
I was trying to use the VS2010 solution in spring\rts\build\vstudio10.

As for what I intend to accomplish, I want to inspect the netcode, and am curious how Lua interacts with everything. I will be trying to prototype something, and I expect I could probably do most of it in Lua, but at some point I will probably roll up my sleeves and change something in the engine to support x or y.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Problems with Boost when building on Windows

Post by abma »

that the master branch. at the time you cloned it it was 91.0, now its 92.0 when you update it. as you try to develop something new, you should use the develop branch, as merging back is much easier.

also the latest master / develop contains fixes that allows to generate a vs project file with cmake that should work. i heavily suggest to switch to the develop branch by
git checkout origin/develop -b develop

this should also fix your chrono linker errors (and hopefully not reval different errors)

only caveat is, that it won't sync with other players that have not the same version. to get the version you can also type "git describe"
I will be trying to prototype something, and I expect I could probably do most of it in Lua, but at some point I will probably roll up my sleeves and change something in the engine to support x or y.
"something" thats a bit unspecific. you should be able to do most tasks easily in lua, for some you'll need some workarounds but most stuff should be possible. i/o to disk is possible, network is possible with lua(sockets), too.

if you give more details maybe we can help more and you maybe safe many time.
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

abma wrote: "something" thats a bit unspecific. you should be able to do most tasks easily in lua, for some you'll need some workarounds but most stuff should be possible. i/o to disk is possible, network is possible with lua(sockets), too.

if you give more details maybe we can help more and you maybe safe many time.
Well I'm fine with wasting some time really. I want to basically poke the engine, recompile it, and see if I can get it to do something different. I don't really have a larger vision than that for starters. Still, I like to have a stable source for that, in those cases that I find something worth a patch, so I can send it upstream. Now, if I'm wasting your time with this stuff, then let me know and I'll just hold off.

I needed a little time to try out the dev branch. The default VS2010 solution is missing many files:

Code: Select all

1>c1xx : fatal error C1083: Cannot open source file: '..\..\Game\OSCStatsSender.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: '..\..\System\mmgr.cpp': No such file or directory
1>  LobbyConnection.cpp
1>c1xx : fatal error C1083: Cannot open source file: '..\..\Lua\LuaLobby.cpp': No such file or directory
1>  ScriptHandler.cpp
1>  UpdaterWindow.cpp
1>c1xx : fatal error C1083: Cannot open source file: '..\..\lib\lobby\RawTextMessage.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: '..\..\lib\oscpack\OscTypes.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: '..\..\lib\oscpack\OscOutboundPacketStream.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: '..\..\lib\lobby\Connection.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: '..\..\Menu\LobbyConnection.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: '..\..\Menu\ScriptHandler.cpp': No such file or directory
1>c1xx : fatal error C1083: Cannot open source file: '..\..\Menu\UpdaterWindow.cpp': No such file or directory
I see them all in the project, but not the filesystem. I could just remove them from the project, and hope for the best, but every error or crash that comes up after that would probably be suspect. Anyways, I'm trying cmake now . . .
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Problems with Boost when building on Windows

Post by abma »

the VS project file (s) ? aren't regulary updated as most devs work on linux and use cmake, so it should be safe to remove the files. i think its best if you create the VS file with cmake...

the command should be cmake -G "Visual Studio 10" i guess or something similar. but this will only work with the source of spring >=92.0 and is bleeding edge, so mostly untested. MadrMen can maybe help if you've problems with it as he wrote the patch that made it work.

just "wasting your time" sounds a bit boring, do something useful ;)
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

Well I might be fixing your Windows build process hahaha.

Speaking of cmake, I tried the mingw build and that complained about chronos, but in a new and interesting way:

Code: Select all

Linking CXX executable ..\..\..\spring.exe
c:/mingw32/bin/../lib/gcc/mingw32/4.7.0/../../../../mingw32/bin/ld.exe: cannot find -lboost_chrono-mt
collect2.exe: error: ld returned 1 exit status
mingw32-make[3]: *** [spring.exe] Error 1
mingw32-make[2]: *** [rts/builds/default/CMakeFiles/engine-default.dir/all] Error 2
mingw32-make[1]: *** [rts/builds/default/CMakeFiles/install-spring.dir/rule] Error 2
mingw32-make: *** [install-spring] Error 2
I would have posted sooner, but I realized the first time around I hadn't placed mingwlibs into that filesystem. Heck, I was about to submit and saw it was missing from the actual build directory cmake was using too. :oops: I think I'm going to look up some syntax to see if I can get more verbose logging. I think it's more conspicuous when it's claiming a file is missing when it's in the right spot. This time I wonder if this a problem somewhere between my keyboard and my chair.
abma
Spring Developer
Posts: 3798
Joined: 01 Jun 2009, 00:08

Re: Problems with Boost when building on Windows

Post by abma »

does the file libboost_chrono-mt.a exist in mingwlibs? maybe you just have to update mingwlibs as chrono was added 7 days ago...

you get (much more verbose) logging when you compile with "make VERBOSE=1"

also i heavily suggest to use ninja, this will heavily speed up compile in comparison to mingw32-make.

download ninja.exe from https://github.com/martine/ninja/downloads and maybe at easiest place into the root of spring source. mingwlibs should be directly placed into the source dir too, so you don't have to set any paths / parameters.

then run "cmake -G Ninja" and "ninja spring" to compile spring.exe... for the moment you can skip ninja and try first to get it compile.
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

I've confirmed libboost-chrono-mt.a is in mingwlibs.

My compile times aren't that bad. I threw together a new system during the last holidays, and got an SSD on which I compile. Granted, the honeymoon period will wear off, and then I'll be looking out for any extra help. IIRC there was something like an accelerator like that on the Ubuntu instructions. I had tried it on a VM image and that all built fine, BTW.

It's more about me sitting down here and being able to look at everything sometimes.

I figured out how to generate a Visual Studio 2010 solution from cmake-gui. I noticed that when I popped into Visual Studio, the dev branch was very different. I was getting a flat filesystem in the stable branch, and here there's now a breakdown of the core units into distinct projects. Still, this one is just failing to compile even before I link.

Here's an abridged error summary, that you might have to copy and paste into a wide window to see right:

Code: Select all

Error	118	error C1083: Cannot open include file: 'OOAICallback.h': No such file or directory	C:\coding\spring\AI\Skirmish\CppTestAI\src\AIExport.cpp	7
Error	119	error C1083: Cannot open include file: 'OOAICallback.h': No such file or directory	c:\coding\spring\ai\skirmish\cpptestai\src\CppTestAI.h	7
Error	128	error C1083: Cannot open include file: 'stdbool.h': No such file or directory	C:\coding\spring\AI\Wrappers\CUtils\SharedLibrary.h	26
Error	129	error C1083: Cannot open include file: 'stdbool.h': No such file or directory	C:\coding\spring\AI\Wrappers\CUtils\SharedLibrary.h	26
Error	112	error C1189: #error :  You should copy include/SDL_config.h.default to include/SDL_config.h	c:\coding\spring\include\sdl\SDL_config.h	34
[This SDL_config.h.default comes up over and over.  I imagine I could do the rename, but I suspect it's not going to clear everything else up]
Error	113	error C2039: 'sqrtf' : is not a member of 'math'	C:\coding\spring\rts\System\FastMath.h	148
Error	114	error C2039: 'sqrtf' : is not a member of 'math'	C:\coding\spring\rts\System\FastMath.h	154
[The sqrtf error happens over and over and over.  It's odd since Microsoft's stuff does have awareness of sqrtf, but in FastMath it's trying to map it to math::sqrtf]
Error	130	error C2057: expected constant expression	C:\coding\spring\AI\Wrappers\CUtils\SSkirmishAISpecifier.cpp	87
Error	132	error C2133: 'hashString' : unknown size	C:\coding\spring\AI\Wrappers\CUtils\SSkirmishAISpecifier.cpp	87
Error	131	error C2466: cannot allocate an array of constant size 0	C:\coding\spring\AI\Wrappers\CUtils\SSkirmishAISpecifier.cpp	87
Error	3	error C2491: 'glActiveTexture' : definition of dllimport function not allowed	C:\coding\spring\rts\lib\headlessStubs\glstub.c	25
[A whole lot of dllimport problems with glstub.c]
Error	249	error C3861: 'snprintf': identifier not found	C:\coding\spring\tools\unitsync\test\lua2php.cpp	137
Back to mingw. I think I want to eliminate the build directory I was using since that stayed in place between switching branches. If it still screws up, I'll try to get verbose output.
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

When I recreated the cmake build directory I was using for a mingw compile, I was finally able to get it to build in there.
Rocko Bonaparte
Posts: 10
Joined: 10 Feb 2013, 06:57

Re: Problems with Boost when building on Windows

Post by Rocko Bonaparte »

I'll see if I can be some use to the project by trying to get that Visual Studio project generation process fixed myself, but not this week due to an emerging family emergency. I've been mostly using the Microsoft toolchain for my own personal stuff, and this goes back to awhile ago when I was last going over all the different build systems that were out there. For whatever reason, I didn't know about cmake's ability to generate makefiles across platforms. Is that new in the past 2-3 years or something? I must have totally missed it; it looks like something I should consider learning about anyways.

So from my point of view, I was able to run the mingw process successfully, and I'll otherwise by unresponsive for the next ~5-7 days.
gajop
Moderator
Posts: 3051
Joined: 05 Aug 2009, 20:42

Re: Problems with Boost when building on Windows

Post by gajop »

cmake can not only generate cross platform make files, it can also generate visual studio projects
heroboy_ywq
Posts: 2
Joined: 05 Mar 2013, 03:11

Re: Problems with Boost when building on Windows

Post by heroboy_ywq »

I have successfully built it on windows with vs2010.
Here is my steps:
1. download cmake
2. get source code from https://github.com/spring/spring (develop branch)
3. get source code from https://github.com/spring/vclibs10 (not download the zip file from website,it not contain boost chrono)
4. run "Visual Studio Command Prompt (2010)",and run cmake-gui.exe in this console.
5. click "Configure"
6. after configure done, check the "Advanced" check box,and search "GIT_EXECUTABLE" and set it to git.exe path.
7. click "Generator",then the vs2010 solution files will generate.
8. build "generateVersionFiles" project,and "VersionGenerated.h" will generate at "src-generated\engine\System".
9. in "engine-default" project add include path:"F:/github/spring/vclibs/freetype/include/".(above "F:/github/spring/vclibs/freetype/include/freetype2" is this a mistake,or freetype2 is not include in vclibs10?)
10. compile "engine-default".(maybe it has some compile error,but they are easy to solve)
Post Reply

Return to “Engine”