I struggled most of yesterday with getting everything to compile under Visual Studio 2008 express (aka VC9), and judging by the forum posts I'm not the only one who has run into trouble there. Since there aren't any apparent solutions posted anywhere I figured I might share how I managed to cobble it together.A: Building GiGi
Problem: SCons is incapable of finding the new Windows SDK (headers and libs) that comes with VC9, so it won't even be able to find essential stuff like windows.h. According to mailing lists a SCons dev is hard at work adding support for this, but it'll be a while until it reaches the release versions.
Solution: As a temporary fix/ugly hack to get SCons to read the paths and compile GiGi, you can read the paths through environment variables instead. The best way to set these variables is to run the Visual Studio Command Prompt (you find the shortcut in its start menu folder). To get the paths into SCons I modified these instructions
I added the following function to build_support.py
from SCons.Util import *
def ENV_update(tgt_ENV, src_ENV):
for K in src_ENV.keys():
if K in tgt_ENV.keys() and K in [ 'PATH', 'LIBPATH',
'LIB', 'INCLUDE' ]:
and this line to SConstruct
in the build vars section.
After that, SCons built GiGi.dll and GiGiSDL.dll happily. B: Building FreeOrion
Problem 1: Boost ASIO complains violently during compile, primarily in old_win_sdk_compat.hpp. Also a problem with the new windows SDK.
Solution: The following change, extracted from asio CVS, should fix the compile errors. It may be necessary/prudent to update the asio files to the newest release, 0.3.9, first before applying the patch (I did). If you do, you will have to compile the boost_system library, which might also require rebuilding all of Boost with VC9. For that, see section C.
@@ -55,9 +55,19 @@
- u_char s6_addr;
+ u_char Byte;
+ u_short Word;
+ } u;
+#define _S6_un u
+#define _S6_u8 Byte
+#define s6_addr _S6_un._S6_u8
Problem 2: Odd compile errors in various windows SDK headers (e.g. winsock header).
Solution: Define _WIN32_WINNT from preprocessor arguments in all three FreeOrion solutions according to the list at this link
(Do not remove thhis preprocessor argument as I wrote earlier).
This should be enough to get FreeOrion to compile as well.C: Rebuilding Boost for VC9
I'm not sure if this is necessary, hopefully it isn't. I did this first, before compiling GiGi and FreeOrion though. Beware that it takes a couple of hours and a good bit of disk space to do.
Download the latest boost release, 1.34.1, from http://www.boost.org
. Then you need to patch in support for VC9. Just follow this excellent guide
. Don't forget to update ASIO to 0.3.9 and build boost_system. When it was all done I just replaced the boost folder in the FreeOrion SDK with the freshly built ones, copied the appropriate Boost_Python dll to the FreeOrion root folder, and updated the freeOrionca solution so the linker finds the new boost_python lib.
Quick n' Dirty, but hopefully someone might find this useful. I guess I should add that I get the VC9-built FreeOrion to run, but I'm currently running into some kind of network error when trying to start a new game, so there might still be some issues caused by VC9.