Compile In Mac OS X

From FreeOrionWiki
Jump to: navigation, search

Preliminary

This page contains the compile instructions for OSX with CMake and Xcode. Consequently, they have been made with the assumption in mind that you have at least some basic understanding of CMake and Xcode - what these tools are, how to use them (specifically, how to use them to compile C++ programs). We do not provide "Getting started with CMake/Xcode" guides here. If you don't know anything about CMake or Xcode yet, we encourage you to take a look at the CMake and Xcode documentations to make yourself familiar with these tools.

The same applies to the version control system the FreeOrion project uses for collaboration. As of March 29th, 2015, this is Git. You will need it to get the current sources, and keep them up to date.

Latest Version

This section is about compiling the latest version of FreeOrion on Intel Macs with CMake and OS X 10.10 (Yosemite) or later. Note: Using CMake to build FreeOrion on OSX has been introduced by commit/revision 3dde6d83, so will only work from that commit/revision onward. Following the instructions will check out the latest version of the source code from the new Git repository on GitHub anyway, so you don't need to worry about that. However, if you want to work with older versions of the source code (for whatever reason), you need to keep that in mind.

The application bundle that will get created when you follow these instructions should run on OS X 10.9 (Mavericks) or later. If that's not the case, please let us know.

The manually maintained Xcode project required to build versions of FreeOrion prior to 3dde6d83 has been discontinued. Furthermore, building FreeOrion with versions of Xcode and OSX prior to Xcode 6 and OSX 10.10 has been deprecated. You can find links to old wiki pages containing instructions for building commits/revisions of FreeOrion prior to 3dde6d83, or for building on OSX 10.6 with Xcode 3 and earlier at the bottom of this page. You'll need the latter specifically if you want to compile versions of the source code prior to revision 7120 in the old FreeOrion SVN repository.

Hardware Requirements

Intel Mac

CPU: Minimum: Core2 Duo; Recommended: Core i5 or better

RAM: Minimum: 4GB; Recommended: 8GB or more (the more the better...)

Software Requirements

Mac OS X 10.10 or later - Make sure all the latest updates and patches are installed.

Xcode 6.4 or later - Just get the latest version of Xcode from the Mac App Store for free.

Git - Git should be automatically installed when you install Xcode. If not, you can download Git for Mac here.

The latest version of the FreeOrion SDK - download from GitHub.

Build Directions

Step by step

  • Open the SDK .dmg file you've downloaded.
  • Copy the contents of the .dmg file to an empty folder, which will be your working copy.
  • Run the bootstrap.command file.
  • When FreeOrion has finished updating, close the terminal.
  • It is strongly recommended to create an extra build directory for CMake to use for the build tree, preferrably outside the working copy folder containing the source.
  • Open the terminal, and cd into the build directory you just created.
  • Run cmake -G Xcode path/to/source/ (where "path/to/source" is the path to your working copy, see above).
  • This will create a lot of stuff in your build directory, among other things a Xcode project FreeOrion.xcodeproj. Open that with Xcode.
  • The active scheme should be set to either 'ALL_BUILD'. As that is the default scheme it should be set anyway. Building it will produce the FreeOrion application. If you want to create a DMG file containing the application for distribution, you need to set the active scheme to 'package'.
  • Start the build process (press 'Command + B').
  • Depending on your system, this may take quite a while (on older systems probably more than 40 minutes). Note that the build process is very resource consuming, so your computer might turn unresponsive while building or even throw some strange build errors. In this case just restart the build process. Lather, rinse, repeat until building succeeds. However, this shouldn't take you more than three tries. If the errors persist, it's either because there is something wrong that's not caused by overtaxing your system (in which case please post a report on the forums), or your computer simply is not up to the task - in that case, sorry, there's nothing we can do about it.
  • After the build process has finished, a 'Release' folder should have been created in your build directory. The FreeOrion application bundle is in that 'Release' folder. If you have built the 'package' build target, a DMG file should have been created in the build directory.
  • 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 git pull command before building.

tl;dr

  • Download and unpack the SDK
  • Run the bootstrap.command script
  • Create a build directory
  • Cd into the build directory and create the build tree with CMake, and specify the Xcode generator
  • Build the generated Xcode project in Xcode

Troubleshooting

Build process aborts after each error

Go to Xcode preferences, 'General' tab, check 'Continue building after errors'. This will cause the build process not to abort immediately after it encounters a build error.

Build process seems to choke system

You can try to disable the 'Parallelize Build' option in the 'ALL_BUILD' or 'package' schemes (whatever you decided to use). This option can be found in the 'Build' profile of the Edit Scheme dialog.

Other issues / errors / problems

Please post on the forums.

Old / obsolete Versions

Compiling with Xcode 6 on OS X 10.10 prior to commit 3dde6d83

The old instructions for compiling with Xcode 6 (or later) on OS X 10.10 (or later) prior to commit 3dde6d83 can be found here. If you want to build FreeOrion from source code versions prior to that commit, you'll need to follow the instructions on that page.

Compiling with Xcode 3 on OS X 10.6

The old instructions for compiling with Xcode 3 on OS X 10.6 can be found here. If you want to build FreeOrion from source code versions prior to revision 7120 in the old FreeOrion SVN repository, you'll need to follow the instructions on that page.

Compiling on OS X 10.5 or earlier

Even older instructions for compiling FreeOrion with Xcode 2 on OS X 10.5 or earlier version can be found here. Note: These instructions have been copied from their original page almost without any adjustments, merely to keep them somewhere. If you're really crazy enough to try to build FreeOrion on OS X 10.5 or earlier, you might find something useful there. Be warned that we can't provide any help or support with that, so you're on your own.