Compile In MacOsX
This section is about compiling the latest version of FreeOrion for Intel Macs with OSX 10.6+. In case you want to compile FreeOrion for older versions of OS X, you're most probably out of luck. You can have a look at the 'Old SDK' section (see below), but the information there is really out of date, it's very likely completely useless by now. But of course, you can try your luck...
CPU: Mimimum: Core2 Duo; Recommended: Core i5 or better
RAM: Minimum: 4GB; Recomended: 8GB or more (the more the better...)
Mac OS X 10.6.8 or later
Xcode 3.2 or later - Just get the latest version of Xcode from the Mac App Store for free.
Subversion - Subversion should be automatically installed when you install Xcode.
The latest version of the FreeOrion SDK
Step by step
- Open the SDK .dmg file you've downloded
- Copy the 'FreeOrionSDK' folder contained there to a directory of your choice
- Run the bootstrap.sh file inside the copied 'FreeOrionSDK' folder
- Accept any certificates if SVN asks you to
- Get a beverage of your choice or go for a walk
- When FreeOrion has finished updating, close the terminal
- Open the Xcode project located at 'FreeOrionSDK/FreeOrion/Xcode'
- If you are using Xcode 4 or later: uncheck "allow debugging when using document revision mode" in the options tab of the run section of the scheme for for FreeOrion, if you don't do this, the resulting FreeOrion app bundle might crash when run (details can be found in this forum thread)
- 'Active Configuration' must be set to either 'Test' or 'Release'. Note: 'Test' builds the binaries with additional safety checks ("assertions") enabled, resulting in program abortions when these safety checks fail. So, if you aim for serious testing and uncovering of issues, use 'Test', if you just want to happily play with a most up-to-date binary and not be bothered by program abortions because some minor internal safety checks fail, use 'Release'.
- 'Active Target' must be set to 'FreeOrion'
- 'Active Executable' must also be set to 'FreeOrion'
- 'Active Architecture' must be set to 'i386' (it's the only choice anyway)
- Press 'Command + B'
- Get another beverage or go for another walk. Note that you computer might turn unresponsive while building (it can take about 40+ minutes for the initial build). There also might occur segfault errors, just let the build process continue until it's finished, then press 'Command + B' again. Lather, rinse, repeat until the build process succeeds. However, this shouldn't take you more then three tries. If it doesn't build after he third try, your computer probably is not up to the task - sorry.
- If the build succeeds you should see a new folder 'build' in the same directory the Xcode project is in. The newly built FreeOrion app bundle can be found in a folder with the name of the build configuration you've chosen ('Test' or 'Release') inside this 'build' folder.
- If the build fails, check out the troubleshooting section of this article, or post on the forums
To keep your sources up-to-date you have to use the svn update method before building (Xcode should not run at that time). You can also use Xcode's built-in SVN client, but it is kind of slow.
In a nutshell
- Download and unpack the SDK
- Run the bootstrap.sh script
- Build the project in Xcode
Troubleshooting and keeping your project up-to-date
Updating the version number
The version information of FreeOrion in OS X is stored in two files:
- Info.plist (bundle version and bundle versions string, short)
Adding new source files
When you get errors like
Undefined symbols for architecture i386: "_condition3_p", referenced from: (anonymous namespace)::Init()in libCommon.a(ConditionParser.o) ld: symbol(s) not found for architecture i386 collect2: ld returned 1 exit status
it is likely that there is a file missing in the target you get the error from.
To add the file ('ConditionParser3.cpp' in this case), just drag it into the 'Compile Sources' section in the 'Build Phases' window of the target.
Other Compilation Errors
You can report errors not listed here on the forums.
ATTENTION: This section is severely out of date. The instructions provided here are no longer useful with current FreeOrion SVN revisions.
If you want to try your luck at compiling FreeOrion for OS X <= 10.5, the following information might be useful.
As of Nov. 20, 2007 you can download an SDK which contains all the necessary libraries as universal binaries and an Xcode project.
Note: the log4cpp, graphviz and DevIL dependencies listed on this page are no longer required for FreeOrion. Instructions relating to them are out of date.
- Xcode >= 2.5. To compile FreeOrion you need the Developer Tools which can be downloaded from Apple. If you already have Xcode installed but it is older than 2.5 you should update.
Download the SDK from SourceForge and unpack it. A current limitation of the Xcode project requires that it be unpacked to a filesystem path that contains no space characters.
In the newly created "freeorion-sdk/FreeOrion/Xcode" directory you will find the Xcode project and library dependencies required to build.
The included SVN revision for FreeOrion and FreeOrion/GG are a snapshot of the last release. Checking out or updating to the most recent revisions may require that you modify the Xcode project to:
- include any new sources added to FreeOrion or GG reversion control
- remove old sources that were deleted from FreeOrion or GG revision control
- make any new Mac specific code changes that resolved a Mac specific compilation error (possibly non-trivial)
- if you're using the SDK packaged for the 0.3.13 release (Jun 13), it may include locally modified source files that will conflict with latest versions. When updating, just choose to abandon the local changes and go with "theirs".
Patches that update the Xcode project or Mac build are welcome.
- GCC 4.2 does not work to build use GCC 4.0 for now (with base SDK set to 10.4 in project settings)
- The dependency on DevIL has been removed, but the Mac OS X build is still configured to use it.
The libraries (with include files) in the SDK are:
- Dynamic Libraries
- DevIL (only linked against libpng)
- Static Libraries
- Boost (only filesystem, python, serialization, signals, thread)
Building the Libraries by yourself
It's best to just stick with the SDK and just build the libraries yourself if you encounter problems with the ones included in the SDK.
Most of the problems with building the libraries arise because not all of them are that easy to build as universal binaries. In the worst case you'll have to build the binaries twice and then combine the result using
The following versions are known to work:
- SDL 1.2.11
- log4cpp 0.3.5 rc3
- graphviz 2.20.3: building from source is necessary to get the libgvc_builtins library
- freetype 2.2.1
- libpng 1.2.12
- log4cpp 0.3.5 RC3
- Boost 1.42.0
- DevIL 1.6.8 RC1 (RC2 has problems with aclocal and automake)
- Python 2.5.5
Ogre can be built easily via their CMake system and Xcode project. They also provide pre-compiled dependency libraries which will also need to be copied into the FreeOrion SDK.
Python 2.6 may result in a FreeOrion build time incompatibility on OS X 10.4, while Python 2.4 doesn't seem to be able to used to build FreeOrion on either 10.4 or 10.5.
./configure --enable-universalsdk=/Developer/SDKs/MacOSX10.4u.sdk/ --prefix=$HOME/local/python-2.5.5 --enable-framework make make install
It may try to write the framework to /Library/Frameworks/Python.framework
Build this after python:
./bootstrap.sh --prefix=$HOME/local/boost_1_42_0 --with-python-root=$HOME/local/python-2.5.5 ./bjam link=static variant=release threading=multi macosx-version-min=10.4 install
SDL, Ogg, Vorbis
Building those is pretty straightforward. They all come with an Xcode project supplied. Just make sure that the install_path of the Framework is configured correctly if you plan on having it in the application bundle.
The produced Ogg/Vorbis frameworks have internal headers that may need to be renamed to support case sensitive filesystems. And the Vorbis.framework itself might need to be renamed to vorbis.framework.
./configure make CC="gcc -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk
log4cpp 0.3.5 rc3
open include/log4cpp/manipulator.hh and remove ';' on line 29
./configure CXX="g++ -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" make clean make cd src/ mkdir .lipos mv .libs/liblog4cpp.4.0.5.dylib .lipos/ mv .libs/liblog4cpp.a .lipos/ cd ..
./configure CXX="g++ -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk" make clean make cd src mv .lipos/liblog4cpp.4.0.5.dylib .libs/liblog4cpp.4.0.5.dylib_i386 mv .lipos/liblog4cpp.a .libs/liblog4cpp.a_i386 rmdir .lipos cd .libs lipo -arch i386 liblog4cpp.4.0.5.dylib_i386 -arch ppc liblog4cpp.4.0.5.dylib -create -output liblog4cpp.4.0.5.dylib lipo -arch i386 liblog4cpp.a_i386 -arch ppc liblog4cpp.a -create -output liblog4cpp.a rm liblog4cpp.a_i386 rm liblog4cpp.4.0.5.dylib_i386 sudo make install
./configure --prefix=$HOME/local/graphviz-2.20.3 --disable-swig --disable-sharp --disable-guile --disable-io --disable-java --disable-lua --disable-ocaml --disable-perl --disable-php --disable-python --disable-r --disable-ruby --disable-tcl --disable-ltdl --without-freetype --without-x CFLAGS="-arch i386 -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" LDFLAGS="-isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 -arch i386" make make install
Mac OS X 10.3 and later ship with GNU libtool, albeit under a slightly different name, glibtool. We need only link to it to build the dynamic version of libjpeg that GD4O needs to work. Change into the build directory:
cd ../jpeg-6b/ ln -s `which glibtool` ./libtool
However, on Mac OS X 10.4 (Tiger), the libtool needs to be specified the build environment. Enter:
setenv MACOSX_DEPLOYMENT_TARGET 10.4
in tcsh, or:
in bash. Now configure with shared library support, then build and install:
./configure --enable-shared && make && sudo make install
configure will complain about ltconfig: cannot guess host type; you must specify one. An alternative to symlinking libtool is to copy its skeletal configuration defaults, as suggested by a correspondent (meaning, I haven't verified this):
cd ../jpeg-6b cp /usr/share/libtool/config.sub . cp /usr/share/libtool/config.guess . ./configure CC="gcc -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk" --enable-shared make sudo make install sudo ranlib /usr/local/lib/libjpeg.a
The freetype library is the same one that is included with the precompiled Ogre dependencies.
This section is probably dated...
Make sure that there is no previous version installed under /usr/local/lib that could be found by configure. Otherwise this can break the build process
sudo rm -rf /usr/local/include/IL sudo rm /usr/local/lib/libIL*
aclocal automake ./configure CC="gcc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk" CPP="/usr/bin/cpp" CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" make clean make cd src-IL/src/ mkdir .lipos mv .libs/libIL.1.0.0.dylib .lipos/ cd ../.. cd src-ILU/src/ mkdir .lipos mv .libs/libILU.1.0.0.dylib .lipos/ cd ../.. cd src-ILUT/src mkdir .lipos mv .libs/libILUT.1.0.0.dylib .lipos/ cd ../.. ./configure CC="gcc -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk" CPP="/usr/bin/cpp" CFLAGS="-I/usr/local/include" LDFLAGS="-L/usr/local/lib" make clean make cd src-IL/src/ mv .lipos/libIL.1.0.0.dylib .libs/libIL.1.0.0.dylib_i386 rmdir .lipos cd .libs lipo -arch i386 libIL.1.0.0.dylib_i386 -arch ppc libIL.1.0.0.dylib -create -output libIL.1.0.0.dylib rm libIL.1.0.0.dylib_i386 sudo /usr/bin/install -c libIL.1.0.0.dylib /usr/local/lib/libIL.1.0.0.dylib cd ../../.. cd src-ILU/src/ mv .lipos/libILU.1.0.0.dylib .libs/libILU.1.0.0.dylib_i386 rmdir .lipos cd .libs lipo -arch i386 libILU.1.0.0.dylib_i386 -arch ppc libILU.1.0.0.dylib -create -output libILU.1.0.0.dylib rm libILU.1.0.0.dylib_i386 sudo /usr/bin/install -c libILU.1.0.0.dylib /usr/local/lib/libILU.1.0.0.dylib cd ../../.. cd src-ILUT/src/ mv .lipos/libILUT.1.0.0.dylib .libs/libILUT.1.0.0.dylib_i386 rmdir .lipos cd .libs lipo -arch i386 libILUT.1.0.0.dylib_i386 -arch ppc libILUT.1.0.0.dylib -create -output libILUT.1.0.0.dylib rm libILUT.1.0.0.dylib_i386 sudo /usr/bin/install -c libILUT.1.0.0.dylib /usr/local/lib/libILUT.1.0.0.dylib cd ../../..
(sudo cd /usr/local/lib && sudo rm -f libIL.1.dylib && sudo ln -s libIL.1.0.0.dylib libIL.1.dylib) (sudo cd /usr/local/lib && sudo rm -f libIL.dylib && sudo ln -s libIL.1.0.0.dylib libIL.dylib) (sudo cd /usr/local/lib && sudo rm -f libILU.1.dylib && sudo ln -s libILU.1.0.0.dylib libILU.1.dylib) (sudo cd /usr/local/lib && sudo rm -f libILU.dylib && sudo ln -s libILU.1.0.0.dylib libILU.dylib) (sudo cd /usr/local/lib && sudo rm -f libILUT.1.dylib && sudo ln -s libILUT.1.0.0.dylib libILUT.1.dylib) (sudo cd /usr/local/lib && sudo rm -f libILUT.dylib && sudo ln -s libILUT.1.0.0.dylib libILUT.dylib)
sudo mkdir /usr/local/include/IL sudo /usr/bin/install -c -m 644 include/IL/il.h /usr/local/include/IL/il.h sudo /usr/bin/install -c -m 644 include/IL/ilu.h /usr/local/include/IL/ilu.h sudo /usr/bin/install -c -m 644 include/IL/ilut.h /usr/local/include/IL/ilut.h sudo /usr/bin/install -c -m 644 include/IL/il_wrap.h /usr/local/include/IL/il_wrap.h sudo /usr/bin/install -c -m 644 include/IL/config.h /usr/local/include/IL/config.h sudo /usr/bin/install -c -m 644 include/IL/devil_internal_exports.h /usr/local/include/IL/devil_internal_exports.h sudo /usr/bin/install -c -m 644 include/IL/ilu_region.h /usr/local/include/IL/ilu_region.h
Please report compilation errors in the forums.
Please report runtime errors in the forums.