This page covers building Freeciv from source on Mac OS X.

As an easier option, you may instead want to investigate using a package manager as described at Install-MacOSX.

The contents are taken, in part, from here.

This page assumes familiarity with development tools like make [ gcc] and git.

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
    • 10.8 (Mountain Lion) - You must install XQuartz; Mountain Lion no longer includes X11 - see HT201341

(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) (deprecated)

the x11 / quartz choice is purely a Mac issue, and does not seem to be covered elsewhere.

Before You Start Edit

There are several tools that are useful in this process, and will make our job *much* easier. These are:

  • Git revision control system. Similar to Subversion or cvs.
  • MacPorts package system for many open source packages
  • Homebrew Package system. Similar to MacPorts.
  • Fink Package system. Similar to MacPorts.

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.

These days, Homebrew is gaining popularity as package manager for macOS, so I added a section for this. --hima (talk) 06:41, November 28, 2017 (UTC)
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.‎

Prepare Mac OS X Edit

Installing MacPorts Edit

  • 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 Homebrew Edit

Installation of Homebrew is well documented on the Homebrew website

Similarly to MacPorts, the default install path is /usr/opt/local* so you may need to do a similar trick as above, passing compiler or linker flags, and/or updating the PATH env variable itself. Luckily, the Homebrew package manager will advise you when this is necessary.

At the time of writing (06:39, November 28, 2017 (UTC)) three libraries seem to be particularly troublesome since Apple includes old or incomplete versions of these libraries in the base OS (High Sierra): gettext, libtool, and icu4c. In the case of libtool, Homebrew renames the binaries as 'glibtool' and 'glibtoolize' to avoid conflict which the Freeciv bootstrapping script struggles to detect. See this ticket in the hrm tracker for more information.

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 compatible 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. Edit: As of OS X 10.8, Mountain Lion, XQuartz appears to work (may work on earlier, not tested). )

  • 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 MacPortsEdit

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 from the Freeciv source code repository
  • 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) Edit

This step applies only if you're building from a development version of the source (git) (Option B).

  • Note: This will also run configure. If you know what you're doing, you can pass the 'configure' arguments directly to, and you may then skip step (3) below.

(3) configure Edit

  • Set up your environment:
% env CC="gcc -no-cpp-precomp" CFLAGS="-O3"
Note: As of High Sierra, these parameters don't seem to be necessary anymore. --hima (talk) 06:45, November 28, 2017 (UTC)
  • 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 \
  • 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.

 % ./fcgui

(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]

You might have success in launching the client by simply double-clicking on the client 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.


FreeCiv logo, suitable for use as Macintosh Icon

It is possible with this, the server may not be able to start. This is because even if you set the path in your .profile, the shell script is not run as a login shell and thus the .profile will not be executed so the folder where the server is located may not be in the PATH variable. There is a UNIX trick to force the PATH to include more elements. For instance, if you installed freeciv in /opt/local, you can change your script to read:
do 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:

When running Freeciv's configure script, be sure to use the following option:


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:


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 client in Swedish locale:

  LANG="sv_SE.UTF-8 freeciv-gtk2"

Note that by giving a full locale string as the example above, you avoid potential encoding conversion warnings and glitches.

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.