User:Captainobvious/Mac OS X Intel
From FreeOrionWiki
Contents |
[edit] Introduction
This documents the modifications that I had to make to various open source packages in order to compile FreeOrion on Mac OS X 10.4.7 on Intel Core Duo. Note that many of these modifications are probably kind of hackish, and better ways probably exist. There is no reason I know of that this wouldn't work on PPC as well, and any version of Mac OS X later than 10.4.
[edit] Before You Start
Before I even started with FreeOrion, I had the following developer tools installed.
Apple XCode (with the latest gcc from apple) (updated August 2006) - required to compile anything
Apple X11 (on the Mac OS X install CD under extra tools) - some things link against X, but it might not be required
TeXShop - required because it contains FreeType2, which you'll need
[edit] Order of Installation
This is probably flexible, but here is the order that I installed things. It isn't totally flexible, however, because many of the packages depend on packages higher up in the installation order. For the bigger packages, I had them downloaded and partially compiled while I was installing some of the dependencies, but this is the order things were actually installed.
- SVN 1.3.2
- python 2.4.3
- Scons 0.96.1
- boost 1.33.1
- SDL 1.2.11
- pkg-config 0.20
- libjpeg 6b
- libtiff 3.8.2
- libmng 1.0.9
- Little CMS 1.15
- DevIL 1.6.8
- GiGi
- log4cpp 0.3.5rc3
- fmod 3.75
- expat 2.0.0
- XML::Parser 2.34
- libpng 1.2.12 (not sure you need)
- fontconfig 2.3.2 (not sure you need)
- Cairo 1.2.2 (not sure you need)
- GraphViz 2.8
- GraphViz-Cairo 2.8 (not sure you need)
- FreeOrion
[edit] Things That Are Easy to Compile
Many of the components are easy to download and install. A few have graphical installers, some have .tar.gz files which can be expanded and then you can just type:
>./configure >make >sudo make install
This includes:
- SVN (make sure to do "./configure --with-ssl" and ignore warnings about Berkeley DB)
- pkg-config
- libtiff (run "./configure --with-apple-opengl-framework")
- DevIL (once you have the dependencies installed)
- XML::Parser ("perl Makefile.PL" replaces "./configure") (once you have expat)
- libpng
- fontconfig
- Cairo (once you have the dependencies installed
- GraphViz (get the source, not the GUI installer)
[edit] Things With Small Tweaks
These packages require a little "assistance", but nothing affecting the source code.
[edit] Python
Python installs from a GUI installer. It will modify your .profile file, adding a line like this:
PATH="/System/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
Change that line to these two:
PATH="/System/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:${PATH}"
[edit] Scons
To install scons,
>export SCONS_LIB_DIR=`pwd`/src/engine >cd build/scons >sudo python setup.py install --standard-lib >cd ../.. >python runtest.py -a
That will lead to 56 failed tests, but I ignored this fact. That may be the source of many of the problems with GiGi and FreeOrion, but I don't know how to fix this. Notice that "pwd" is in back-ticks, not single quotes.
[edit] boost
Boost seems to have an error in the building scripts that causes the libraries to not build. Since boost uses #define to override the "main" function, it implements the main function itself, and thus needs to be able to call a user main. This, of course, will be undefined in the library. To fix this, link the library with -Wl,-undefined,dynamic-lookup, which tells the linker to look up the the user functions at runtime. Boost uses a custom "Jamfile" building system, which I was unable to decipher. Fortunately, one can find the errors and compile the library oneself.
>./configure >make >make
Now, find the command boost was trying to execute
c++ -Wl,-x -o "bin/boost/libs/test/build/libboost_unit_test_framework.dylib/\ darwin/release/shared-linkable-true/libboost_unit_test_framework-1_33_1.dylib" \ "bin/boost/libs/test/build/libboost_unit_test_framework.dylib/darwin/release/\ shared-linkable-true/libboost_unit_test_framework-1_33_1.lo" \ -dynamiclib -install_name "libboost_unit_test_framework-1_33_1.dylib"
and add -Wl,-undefined,dynamic_lookup to the end and run it yourself. Then do it five more times for the remaining errors.
In order for scons to find boost, you need to do
>cd /usr/local/lib >sudo ln -s boost-1_33_1/boost boost
[edit] libjpg
Do the usual three commands, and then
>sudo ranlib /usr/local/lib/libjpeg.a
[edit] libmng
Everything works, but you have to install manually.
>./configure >make >sudo cp libmng.a /usr/local/lib >sudo ranlib /usr/local/lib/libmng.a >sudo cp libmng.h libmng_types.h libmng_conf.h /usr/local/include
[edit] Little CMS
Run the usual three commands, and then
>sudo mkdir /usr/local/include/lcms >sudo ln -s /usr/local/include/lcms.h /usr/local/include/lcms/lcms.h
[edit] fmod
Download the Mac OS X version of fmod and expand the disk image.
copy api/inc/*.h to /usr/local/include
copy api/lib/libfmodx86.a to /usr/local/lib/libfmod-3.75.a
>sudo ranlib /usr/local/lib/libfmod-3.75.a
[edit] GraphViz-Cairo
Go to the graphviz-cairo folder and run "./configure", as usual.
Edit plugins/xlib/Makefile. You're looking for a line that says:
CAIRO_LIBS = -L/usr/local/lib -lcairo
and chaning it to
CAIRO_LIBS = -L/usr/local/lib -lcairo -lX11
(You need Apple's X11 for this. On the other hand, if you didn't have X11, maybe configure would have not compiled the portion needing X11.)
Now
>make >sudo make install
[edit] Things With Source Code Edits
These packages had to have actual source changes in order to compile. In a lot of cases, I actually felt like I was fixing something that was an actual bug, but maybe I'm missing something.
[edit] log4cpp
Run configure as usual.
Modify line 29 of Manipulator.hh - delete teh semicolon
Modify PatternLayout.cpp near line 229 - change the type of fillCount from size_t to long
>make >sudo make install
[edit] expat
Edit tests/chardata.h and tests/runtests.c to include ../lib/expat.h, in place of expat.h
Then run the usual sequence of configure, make, make install.
[edit] GiGi
[edit] Scons issues
Scons seems to run into quite a few issues, possibly because it doesn't configure itself perfectly for Mac OS X? Anyway, here are the problems building I ran into and what I did to fix them.
Scons has trouble finding OpenGL, since this is installed in a Mac OS X framework. Ideally scons would know this, but since it doesn't, you can trick it with sym links.
>sudo ln -s /System/Library/Frameworks/OpenGL.framework/\ Libraries/libGL.dylib /usr/local/lib/libGL.dylib
Modify build_support.py in gigi/GG, line 325, from
int main()
to
int main(int argc, char **argv)
It's alright to define main() with no arguments normally, but when a header file (SDL I Think) replaces main with SDLMain, it must conform to the prototype.
This also had to be done in freeorion/FreeOrion/build_support.py, line 297
In gigi/GG/SConstruct, line 309, change from
#if !ILUT_USE_OPENGL
to
#ifndef ILUT_USE_OPENGL
or else scons won't think you have DevIL with OpenGL, because
#if !
by itself is bad C code and ILUT_USE_OPENGL is defined, but to nothing (Both these issues are fixed in RC5)
Also do this in freeorion/FREEORION/SConstruct line 289
In gigi/GG/SConstruct, there are three groups, around line 550, that tell how to install GiGi, GiGiSDL, and GiGiNet. They include clauses like
if env['dynamic']:
Alias('install',
env.Command(lib_dir + '/' + gigi_libname,
lib_dir + '/' + installed_gigi_libname,
'ln -s ' + lib_dir + '/' + installed_gigi_libname + ' ' + lib_dir + '/' + gigi_libname))
Comment these out, because the installed names are the same as the original names (thus causing an attempt to link an item to itself).
Also in the Sconstruct file for GG, around line 484, change
# define libGiGiSDL objects
if not env['disable_sdl']:
sdl_env = env.Copy()
if str(Platform()) == 'win32':
sdl_env.Append(LIBS = ['SDL', 'GiGi'])
if not env['disable_net']:
sdl_env.Append(LIBS = ['GiGiNet'])
to
# define libGiGiSDL objects
if not env['disable_sdl']:
sdl_env = env.Copy()
#if str(Platform()) == 'win32':
sdl_env.Append(LIBS = ['SDL', 'GiGi'])
if not env['disable_net']:
sdl_env.Append(LIBS = ['GiGiNet'])
Note the careful indenting. This is required because SDL, GiGi, and GiGiNet are required libs for GiGiSDL (on darwin as well) Someone with knowledge of an "or" command in python could also add (str(Platform()) == 'win32' OR str(Platform()) == 'darwin'), since that is what the platform is (I've checked with print statements).
Line 29 of gigi/GG/SConstruct also needs to be fixed so that 'darwin' is not handled the same as 'win32' and 'location to install GG' is /usr/local/ rather than C:\\.
[edit] Source Code Edits
All source code edits are no longer necessary in RC5.
In gigi/GG/GG/Texture.h lines 150, 151, change the type of m_width and m_height to be GLint instead of int.
This is important, since the addresses of those variables are passed to a function which takes GLint*.
The following lines appear in gigi/GG/src/SDL/SDLGUI.cpp (around line 208) and freeorion/FreeOrion/client/human/HumanClientApp.cpp (around line 450):
#ifdef __APPLE__
GG::Pt mouse_pos(event.motion.x, m_app_height - event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, -event.motion.yrel);
#else
GG::Pt mouse_pos(event.motion.x, event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, event.motion.yrel);
#endif
First off, this obviously wasn't tested in the freeorion version, since m_app_height is private, and second, the effect seems to be that everybody gets a mouse, except mac users get a weird backwards mouse... maybe it fixed a bug in MacOS that was later fixed by Apple?
In any event change this to:
#ifdef __APPLE__
GG::Pt mouse_pos(event.motion.x, event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, event.motion.yrel);
#else
GG::Pt mouse_pos(event.motion.x, event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, event.motion.yrel);
#endif
[edit] GG-Sketch
This little test app can be used, if you add the following to the Sconstruct file, at the top, near "posix":
# darwin
if platform_str == 'darwin':
print 'Darwin platform detected ...'
gg_dir = '/usr/local/include'
cpppath = ['/usr/local/include/boost-1_33_1',
'/usr/local/include/SDL',
'/usr/local/include/freetype2',
gg_dir]
libs = ['GiGiSDL',
'GiGiNet',
'GiGi',
'boost_signals-d-1_33_1',
'boost_filesystem-d-1_33_1',
'boost_serialization-d-1_33_1',
'SDL',
'SDLmain',
'GL',
'GLU']
ccflags = '-DHAVE_CONFIG_H -D_REENTRANT -Wall -g -O0'
env = Environment(CCFLAGS = '-DLTDL_SHLIB_EXT=\\".dylib\\"',
CPPPATH = cpppath,
LIBS = libs,
LIBPATH = ,
LINKFLAGS = '-Wl,-framework,Cocoa')
[edit] FreeOrion
[edit] Scons issues
Many of these issues are the same as in GiGi, and I reference them there as well.
Modify build_support.py in freeorion/FreeOrion, line 297, from
int main()
to
int main(int argc, char **argv)
(fixed in RC5) In freeorion/FreeOrion/SConstruct, line 289, change from
#if !ILUT_USE_OPENGL
to
#ifndef ILUT_USE_OPENGL
In freeorion/FreeOrion/SConstruct, line 311 add this line
context.env.Append(LIBS = ['SDL', 'SDLmain'])
Scons also wants a FreeOrion/libltdl so I created a link to the version in the GG subdirectory of FreeOrion:
>ln -s FreeOrion/GG/libltdl FreeOrion/ltdl
In freeorion/FreeOrion/SConstruct, line 480, add
env.AppendUnique(LIBS = ['GiGi', 'GiGiNet', 'GiGiSDL'])
[edit] Source Code Edits
(fixed in RC5) In freeorion/FreeOrion/client/human/HumanClientApp.cpp (around line 450) change
#ifdef __APPLE__
GG::Pt mouse_pos(event.motion.x, m_app_height - event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, -event.motion.yrel);
#else
GG::Pt mouse_pos(event.motion.x, event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, event.motion.yrel);
#endif
to
#ifdef __APPLE__
GG::Pt mouse_pos(event.motion.x, event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, event.motion.yrel);
#else
GG::Pt mouse_pos(event.motion.x, event.motion.y);
GG::Pt mouse_rel(event.motion.xrel, event.motion.yrel);
#endif
Then it works!

