Guide (sort of) for building GiGi and FreeOrion under VC9

Questions, problems and discussion about compiling FreeOrion.
Post Reply
Krill Swarm
Posts: 12
Joined: Sat Mar 22, 2008 5:23 pm

Guide (sort of) for building GiGi and FreeOrion under VC9

#1 Post by Olemars » Sun Mar 23, 2008 2:28 pm

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 slightly.
I added the following function to

Code: Select all

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' ]:
            tgt_ENV[K]=AppendPath(tgt_ENV[K], src_ENV[K])
and this line to SConstruct

Code: Select all

ENV_update(env['ENV'], os.environ)
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.

Code: Select all

Index: old_win_sdk_compat.hpp
@@ -55,9 +55,19 @@

struct in6_addr_emulation
-  u_char s6_addr[16];
+  union
+  {
+     u_char Byte[16];
+     u_short Word[8];
+  } u;

+#if !defined(s6_addr)
+#define _S6_un u
+#define _S6_u8 Byte
+#define s6_addr _S6_un._S6_u8
+#endif //!defined(s6_addr)
struct sockaddr_in6_emulation
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 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.

Post Reply