- 9 Talk
-
Build-MacOSX
Contents |
Introduction
Edit
This page covers building freeciv from source on Mac OS X. The contents are taken, in part, from here.
This page assumes familiarity with development tools like make [gcc.gnu.org/ gcc] and subversion.
The good news is that Freeciv compiles on Mac OS X without any source code modification.
This was written with:
- Freeciv
- 2.1.3
- 2.1.10 (installs via macports as freeciv-x11)
- 2.2.0-beta2 (GTK+2 client, compiles from source tarball without modifications using macports for prerequisites)
- Mac OS X
- 10.4.11
- 10.5.8
(please add on if these instructions have worked)
Possible Clients
Edit
Freeciv supports several clients on Mac OS X:
- GTK+1 (deprecated)
- GTK+2 (recommended)
- GTK2 +x11 (ported from linux)
- GTK2 +quartz (under development)
- SDL
- xaw (does not require supporting libraries -- ie. port or fink)
the x11 / quartz choice is purely a Mac issue, and does not seem to be covered elsewhere. --User:Teyrana
Before You Start
Edit
There are several tools that are useful in this process, and will make our job *much* easier. These are:
- subversion revision control system. Similiar to cvs.
- MacPorts package system for many open source packages
- Fink Package system. Similiar to MacPorts, but not as up to date.
Although the source code does not need modification, it takes a good bit of work to lay the foundation so that you can compile Freeciv on top of it. Thankfully heavy lifting can be done for you by a package manager like port or fink, mentioned above.
The toolchains have improved enough that compiling by hand is not that hard. If you can type "./configure" and "make" you should be able to pull this off. Dentrassi BBQ 05:16, April 29, 2010 (UTC)
As of this writing, fink is not as up-to-date as macports. Therefore, I recomend using 'port' as your package manager. -- User:Teyrana
Prepare Mac OS X
Edit
Installing MacPorts
Edit
- Head over to MacPorts, follow the installation instructions to install MacPorts.
- The default install paths for macports is /opt/local/*. Because these aren't always included in the default paths, you may need to add them to the normal compiler search paths:
% export CC="gcc -I/opt/local/include/ -L/opt/local/lib/"
- You will notice this problem if libraries fail to link while compiling.
- Note: At least with MacOSX 10.5.8, only macports is needed. To ease fulfilling the requirements, the package for freeciv-x11 (pointing to 2.1.10 as of current) can be installed and disabled before building freeciv 2.2.0-beta2. This way, all required libraries are installed automagically.
Installing Fink
Edit
Instructions to install Fink can be found here. It's recomended that you use the included FinkCommander. You will want to install the following packages:
(installing the shlib and dev packages is recomended)
GTK +X11
Edit
- Install X11 and X11 SDK components. Both are available on your Mac OS X CD. However, X11 itself is also available as a download (Panther compatable download here) from Apple.
- Install Xcode 1.2, 1.5 (For Panther), 2.0 (For Tiger) or 3.0 (For Leopard)
- GTK+ 2.0 client - If done by a package manager, the supporting packages will be installed automatically.
- gettext
- glib2
- pango
- atk
- gtk2
GTK +quartz
Edit
(Does not yet work. )
- Install Xcode 1.2, 1.5 (For Panther), 2.0 (For Tiger) or 3.0 (For Leopard)
- GTK+ 2.0 client - If done by a package manager, the supporting packages will be installed automatically.
- gettext
- glib2
- pango
- atk
- gtk2
SDL
Edit
As of 2.2.0, the SDL client is not as plush as the GTK client. For instance, the SDL interface does not recognize a scroll wheel on a mouse. GTK not only does, it also recognizes trackpad gestures. Dentrassi BBQ 05:50, April 29, 2010 (UTC)
- There is actually an inline help system there - it's just very well hidden. One entry point that I can recall off the top of my head is in the research target dialog. Click the middle mouse button on top of one of the tech targets to activate the help system. Then you can navigate to the other parts of the UI from there. hima 19:52, February 12, 2010 (UTC)
The required packages are:
Build and install in above order, then compile the Freeciv tarball with "--enable-client=sdl".
If you get stuck, you might get some help from an installation guide for another SDL-based game at [1]
SDL Client with MacPorts
Edit
I've been able to build the SDL client using the libs provided by MacPorts. Changing the "--cflags)" section of /opt/local/bin/sdl-config to
-I${prefix}/include/SDL -D_GNU_SOURCE=1 -D_THREAD_SAFE \
-I${prefix}/include/ -Dmain=SDL_main
Configure and Setup
Edit
(1) Get Source
Edit
- Option A: get source tarball from here and extract it.
- Option B: get a fresh source tree: Svn
- Note where you put this. This directory is the prefix directory. We'll refer to it later.
At this point, it's a good idea to read the INSTALL file located in the top-level directory of the archive. It contains information on dependencies and other useful information.
(2) autogen.sh
Edit
This step applies only if you're building from a development version of the source (subversion).
- Note: This will also run configure. If you know what you're doing, you can pass the 'configure' arguements directly to autogen.sh, and you may then skip step (3) below.
(3) configure
Edit
- Set up your environment:
% env CC="gcc -no-cpp-precomp" CFLAGS="-O3"
- To build the GTK+2 client, execute this configure command from the command line, at the top-level directory of the source archive:
% ./configure \
--enable-client=gtk2 \
--prefix=/Users/your_user_name/freeciv-2.0.4
- Also on Leopard:
--with-readline=builtin --with-libiconv-prefix=${prefix}/include
- As of version 2.1.13 there is a bug which requires building without readline (this bug does not seem to be present in 2.2.0-beta1 onwards):
% --without-readline
- If ngettext isn't found, you will be prompted to add "--disable-nls".
Compile
Edit
(4) Run Make
Edit
- Compile the source by executing this command:
% make
(4b) Troubleshooting
Edit
Potential Errors During Compiling
Edit
Compiling Freeciv using the before specified commands may yield the following error:
stdinhand.c: In function 'freeciv_completion': stdinhand.c:4509: error: 'rl_attempted_completion_over' undeclared (first use in this function) stdinhand.c:4509: error: (Each undeclared identifier is reported only once stdinhand.c:4509: error: for each function it appears in.) make[3]: *** [stdinhand.o] Error 1 make[2]: *** [all-recursive] Error 1 make[1]: *** [all-recursive] Error 1 make: *** [all] Error 2
A workaround for this problem was mentioned at the Freeciv-Dev Mailing list:
You can probably work around it by running ./configure --without-readline. However it would be nice to fix it if you'll help us track down the problem.
This applies to users of Mac OS X 10.4 (Tiger).
If you receive a link error like the following:
Undefined symbols:
"_iconv_close", referenced from:
_convert_string in libfreeciv.a(fciconv.o)
_convert_string in libfreeciv.a(fciconv.o)
"_iconv_open", referenced from:
_convert_string in libfreeciv.a(fciconv.o)
"_iconv", referenced from:
_convert_string in libfreeciv.a(fciconv.o)
_convert_string in libfreeciv.a(fciconv.o)
"_locale_charset", referenced from:
_init_character_encodings in libfreeciv.a(fciconv.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [freeciv-gtk2] Error 1
make[2]: *** [all-recursive] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
It means you are probably linking against iconv version 1.13; you need to install the latest libiconv. You can find instructions here. Untar to a directory and change to it:
% ./configure --prefix=/opt/local % make % sudo make install
Which will install it with the MacBuilds directory or replace /opt/local with /sw for Fink.
Now, you need to reconfigure and rebuild freeciv; switch to your freeciv source directory and type:
% make clean % ./configure --enable-client=gtk2 --prefix=/opt/local --disable-nls --with-libiconv-prefix=/opt/local % make
Install
Edit
(5) Test
Edit
If you've gotten this far, test your shiny new program. This command will run the client.
% ./civ
(6) Install and Enjoy
Edit
Assuming everything works properly, execute this command to install it in directory you specified as the prefix:prefix:
% make install
- Now, you should be able to find some executables in the /prefix/bin directory:
freeciv-gtk2 [or freeciv-sdl] freeciv-server civmanual
You might have success in launching the client by simply double-clicking on the civclient executable from within the Finder, however this will typically pop up a terminal similar to a DOS window on a PC. In order to create a true clickable icon for the finder, you need to use AppleScript. You can find the Script Editor in the Utilities subfolder of the Applications folder. Open that and and enter:
do shell script "/opt/local/bin/freeciv-gtk2"
Or /sw instead of /opt/local depending on whether you installed via Fink; or your home directory path to the executable as the case may be. Save this to your applications folder and select "Application" for the file format and check "Run Only". Click save.

Added by TimeHorsedo shell script "PATH=/opt/local/bin:$PATH /opt/local/bin/freeciv-gtk2"
If you have an icon you want to use such as the one to the left, option-click and Copy Image it into the paste buffer and edit the properties through the Get Info option click on the resulting script in the finder. In the Info window, select the default icon and then press Command-V to paste in your icon.
- Enjoy!
Optional Support
Edit
Sound Support
Edit
You need to install the following for SDL sound support:
- libsdl SDL_sound tarball
- libsdl_mixer SDL_mixer tarball
- libogg libogg tarball * This is needed so that sdl-sound can actually play the sounds in the soundset, which are in OGG format.
When running Freeciv's configure script, be sure to use the following option:
--with-sdl-prefix=/opt/local
Furthermore, you need to define your CC environment variable to be the following:
gcc= " -no-cpp-precomp -I/opt/local/include -L/opt/local/lib"
After you have built the binaries, copy the .soundspec file, and the accompanying folder containing the actual sound files from the sound set archive into your path_to_freeciv/share/freeciv directory.
Localization Support
Edit
You need to have a functioning installation of the gettext package to be able to run Freeciv with a language other than English.
When running Freeciv's configure script, be sure to use the following option:
--enable-nls
Furthermore, you need to define your CC environment variable to be the following (to where MacPorts install packages):
gcc = "-no-cpp-precomp -I/opt/local/include -L/opt/local/lib"
You may start either the server or client or both in the locale of your choice by giving a full LANG prefix when executing them. E.G. the civclient in Swedish locale:
LANG="sv_SE.UTF-8 civclient"
Note that by giving a full locale string as the example above, you avoid potential encoding conversion warnings and glitches.