Difference between revisions of "Compile In Mac OS X"

From FreeOrionWiki
Jump to: navigation, search
m
(Link to previous version of page for old compile instructions.)
(8 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
= Preliminary =
 
= Preliminary =
  
The instructions on this page have been made with the assumption in mind that you have at least some basic understanding of Xcode - what it is, how to use it (specifically, how to use it to compile C++ programs). We do not provide a "Getting started with Xcode" guide here. If you don't know anything about Xcode yet, we strongly encourage you to consult the Xcode documentation to make yourself familiar with it.
+
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 [http://git-scm.com Git]. You will need it to get the current sources, and keep them up to date.
  
 
= Latest Version =
 
= Latest Version =
  
This section is about compiling the latest version of FreeOrion on Intel Macs with Xcode 5 and OS X 10.8 (Mountain Lion) or later. The instructions given here won't work with versions of the source code prior to revision 7120 in FreeOrion's SVN repository. Following the instructions will check out the latest version of the source code 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.
+
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 [https://github.com/freeorion/freeorion/commit/3dde6d83b969ad2fb5eafbc65ac990ca2de312d3 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.7 (Lion) or later. According to our tests it should even run on 10.6 (Snow Leopard), but that is not guaranteed and no longer officially supported (so, if your FreeOrion app does not run on 10.6, filing bug reports or post respective complaints on the [http://freeorion.org/forum/viewforum.php?f=24 forums] won't help). However, if the FreeOrion app you build does not run at least on 10.7, please let us know.
+
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.
  
Support for building FreeOrion with earlier versions of Xcode and OS X has been deprecated, you can find links to the old wiki pages containing instructions for these older versions at the bottom of this page. You'll need this specifically if you want to compile versions of the source code prior to revision 7120 in FreeOrion's SVN repository.
+
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 ==
 
== Hardware Requirements ==
Line 21: Line 23:
 
== Software Requirements ==
 
== Software Requirements ==
  
Mac OS X 10.8 or later - ''Make sure all the latest updates and patches are installed.''
+
Mac OS X 10.10 or later - ''Make sure all the latest updates and patches are installed.''
  
Xcode 5 or later - ''Just get the latest version of Xcode from the Mac App Store for free.''
+
Xcode 6.4 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.''
+
Git - ''Git should be automatically installed when you install Xcode. If not, you can download Git for Mac [http://git-scm.com/download/mac here].''
  
The latest version of the FreeOrion SDK  
+
The latest version of the FreeOrion SDK - ''download from [https://github.com/freeorion/freeorion-sdk/releases GitHub].''
  
 
== Build Directions ==
 
== Build Directions ==
Line 33: Line 35:
 
=== Step by step ===
 
=== Step by step ===
  
*Open the SDK .dmg file you've downloaded
+
*Open the SDK .dmg file you've downloaded.
*Copy the 'FreeOrionSDK' folder contained there to a directory of your choice
+
*Copy the contents of the .dmg file to an empty folder, which will be your working copy.
*Run the bootstrap.command file inside the copied 'FreeOrionSDK' folder
+
*Run the bootstrap.command file.
*Accept any certificates if SVN asks you to
+
*When FreeOrion has finished updating, close the terminal.
*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 Xcode project located at 'FreeOrionSDK/FreeOrion/Xcode'
+
*Open the terminal, and cd into the build directory you just created.
*The active scheme must be set to either 'Test Release', 'Release' or 'FreeOrion'. The first two schemes will create the FreeOrion application bundle and package it into a DMG image file. If you just want the application bundle and no DMG package, select the 'FreeOrion' scheme. ''Note'': 'Test Release' 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 Release'. 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'. 'FreeOrion' will create the same binaries as 'Test Release'.
+
*Run <code>cmake -G Xcode path/to/source/</code> (where "path/to/source" is the path to your working copy, see above).
*Start the build process (press 'Command + B')
+
*This will create a lot of stuff in your build directory, among other things a Xcode project <code>FreeOrion.xcodeproj</code>. Open that with Xcode.
*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 then 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 [http://freeorion.org/forum/viewforum.php?f=24 forums]), or your computer simply is not up to the task - in that case, sorry, there's nothing we can do about it.
+
*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'.
*The location of the FreeOrion application bundle depends on your Xcode settings (see Xcode documentation).
+
*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 [http://freeorion.org/forum/viewforum.php?f=24 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 [http://freeorion.org/forum/viewforum.php?f=24 forums].
 
*If the build fails, check out the troubleshooting section of this article, or post on the [http://freeorion.org/forum/viewforum.php?f=24 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.''
+
''To keep your sources up-to-date you have to use the git pull command before building.''
  
=== In a nutshell ===
+
=== tl;dr ===
  
 
*Download and unpack the SDK
 
*Download and unpack the SDK
*Run the bootstrap.sh script
+
*Run the bootstrap.command script
*Build the project in Xcode
+
*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  ==
 
== Troubleshooting  ==
 
=== Can't find the app bundle / DMG file ===
 
 
Check the Xcode documentation to learn where Xcode places the products it creates during the build process. Quick solution: Go to Xcode preferences, 'Locations' tab, press the button labeled 'Advanced', select the 'Legacy' option. When you start the build process, this will create a new folder 'build' in the same directory the Xcode project is in. In case of a successful build the 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.
 
  
 
=== Build process aborts after each error ===
 
=== Build process aborts after each error ===
Line 65: Line 67:
 
=== Build process seems to choke system ===
 
=== Build process seems to choke system ===
  
You can try to disable the 'Parallelize Build' option in the 'Test Release', 'Release' and/or 'FreeOrion' schemes (whatever you decided to use). This option can be found in the 'Build' profile of the Edit Scheme dialog.
+
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 ===
 
=== Other issues / errors / problems ===
Line 72: Line 74:
  
 
= Old / obsolete Versions =
 
= 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 [[Special:PermanentLink/9384|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 ==
 
== 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 [[Compile_In_Mac_OS_X_10.6|here]]. If you want to build FreeOrion from source code versions prior to revision 7120 in the FreeOrion SVN repository, you'll need to follow the instructions on that page.
+
The old instructions for compiling with Xcode 3 on OS X 10.6 can be found [[Compile_In_Mac_OS_X_10.6|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 ==
 
== 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 [[Compile_In_Mac_OS_X_10.5_or_earlier|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.
 
Even older instructions for compiling FreeOrion with Xcode 2 on OS X 10.5 or earlier version can be found [[Compile_In_Mac_OS_X_10.5_or_earlier|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.

Revision as of 13:46, 1 May 2018

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.