Compilation on Mac OS X

From Stellarium Wiki
(Difference between revisions)
Jump to: navigation, search
m (Prepare Mac OS X to build Stellarium: Changed to current version (4.8.4) Qt libraries)
(Getting rid of very old (more than 3 years!) outdated instructions for an universal build)
 
(42 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
This document describes how to build Stellarium from sources on Mac OS X. This process ought to improve over time.
 
This document describes how to build Stellarium from sources on Mac OS X. This process ought to improve over time.
  
The set of instructions was written for the 0.10.4 release and using an Intel machine with Leopard (10.5). The process has been validated on 10.6, 10.7 and 10.8.x.
+
The set of instructions was written for the 0.13.0 and later releases and using an Intel machine with Mountain Lion (10.8) or later, including Yosemite (10.10.5 at the moment). No universal builds were made since a lot of time (version 0.11.3, 2012-07-31).
  
 
== Prepare Mac OS X to build Stellarium ==   
 
== Prepare Mac OS X to build Stellarium ==   
  
Since Stellarium version 0.10.6, you need a machine with Mac OS X 10.5<ref>If you build Stellarium 0.10.6+ by yourself on Mac OS X 10.4.11 then you need edit info.plist file then change value for LSMinimumSystemVersion key. You'll have to get [ftp://ftp.qt.nokia.com/qt/source/ older versions of Qt (Carbon)] too, if you want to create universal binaries (PPC and Intel).</ref>. These instructions were tested with Mac OS X 10.6 or later, including Mountain Lion (10.8.2 at the time these instructions are written).
+
=== First step: Install Developer Tools and Qt ===
  
# Install the latest version of Apple's Developer Tools: http://developer.apple.com/technology/xcode.html
+
# Install the latest version of Apple's Developer Tools: https://developer.apple.com/xcode/
# Install the latest stable version of Qt Libraries from the dmg (4.8.4 at the time these instructions were written): http://qt-project.org/downloads#qt-lib ([http://releases.qt-project.org/qt4/source/qt-mac-opensource-4.8.4.dmg direct download])
+
# Install the latest stable version of Qt5 (5.4.2 at the moment): http://www.qt.io/download-open-source/ ([http://download.qt.io/official_releases/qt/5.4/5.4.2/qt-opensource-mac-x64-clang-5.4.2.dmg offline installer])
# Install macports: http://www.macports.org/install.php
+
# Add Qt5 to your PATH environment variable, adding to your ''.bash_profile'' file the following line: <code>export PATH=~/Qt/5.4/clang_64/bin:$PATH</code>
# Install cmake using macports: <code>$ sudo port install cmake</code>
+
# Install bazaar using macports: <code>$ sudo port install bzr</code>
+
  
== Compiling dependencies to build an universal binary ==
+
=== Second step: Install CMake and Bazaar ===
  
'''Note: This step is needed only if you need an universal binary. If you don't intend to create an universal package you can skip this and going to the next section [[#Building Stellarium itself|Building Stellarium itself]].'''
+
You need some tools to build Stellarium on OS X. This tools are CMake and Bazaar. There are (at least) two simple options to install these tools on OS X. Choose only one of them (HomeBrew or MacPorts).
  
We have to compile the dependencies with special flags to be able to generate an universal binary.
+
==== Option 1: With HomeBrew ====
  
In case you are compiling in a Leopard or Snow Leopard machine you have to recompile stellarium dependencies making use of the oldest system libraries (in our case those in 10.4 aka Tiger). We need the following compilation flags:
+
Simpler, lighter and safer (doesn't need sudo) than MacPorts.
  
a. We want to generate a single binary for both intel and ppc architectures so:
+
# Install HomeBrew: http://brew.sh
 +
# Install CMake: <code>$ brew install cmake</code>
 +
# Install Bazaar: <code>$ brew install bazaar</code>
 +
# (optional) Install (and link) Gettext: <code>$ brew install gettext; brew link gettext --force</code>
  
-arch i386 -arch ppc
+
==== Option 2: With MacPorts ====
  
b. We want to link with the old framework and system libraries:
+
# Install MacPorts: http://www.macports.org/install.php
 +
# Install CMake: <code>$ sudo port install cmake</code>
 +
# Install Bazaar: <code>$ sudo port install bzr</code>
  
-mmacosx-version-min=10.4
+
=== Last step: Restart terminal session ===
-isysroot /Developer/SDKs/MacOSX10.4u.sdk/ (Not sure if this is really needed)
+
  
=== Compiling dependencies ===
+
Don't forget to restart your terminal session, so that your new PATH setting is taken in account.
 
+
- Libiconv: It's important to compile libiconv in the first place because gettext depends on it. Get the latest release from here: http://www.gnu.org/software/libiconv/ Uncompress the file in your favorite directory and configure and compile like this:
+
 
+
  $ ./configure --prefix=/usr CFLAGS='-arch i386 -arch ppc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/'
+
  $ make
+
  $ make install
+
 
+
- Gettext: Get the latest release from here: http://www.gnu.org/software/gettext/ . Uncompress the file in your favorite directory and configure and compile like this:
+
 
+
  $ ./configure CFLAGS='-arch i386 -arch ppc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/'
+
  $ make
+
  $ make install
+
 
+
At the moment of writing these steps 4.6.2 is the latest version of Qt. Trolltech provides support from MacOS 10.4 to 10.6 so our binaries will be constrained by this. I went through these instructions in a Leopard machine. To compile in Snow Leopard it's necessary to consider the following notes copied from the Qt 4.6.0 changelog:
+
 
+
* Gcc 4.2 is used by default. Configure with -platform macx-g++40 to select 4.0.
+
* Using the 10.4u SDK requires gcc 4.0.
+
* Configuring for the Cocoa port (-cocoa) produces 64-bit binaries by default. Use the -arch flags to override.
+
* Building for ppc64 is no longer supported by the gcc tool chain.
+
* Building for ppc is still supported.
+
 
+
I haven't tried to generate universal binaries on a Snow Leopard machine. We have to validate these steps.
+
  
 
== Building Stellarium itself ==
 
== Building Stellarium itself ==
Line 81: Line 61:
 
  $ cd builds/macosx
 
  $ cd builds/macosx
  
[[Configuring Build Options|We run cmake]]<ref>If you've installed the Qt Creator dmg instead of the Qt Libraries, cmake will complain that it can't find Qt and you'll have to pass as an option the location of your QtSDK installation, e.g.
+
[[Configuring Build Options|We run cmake]]...
$ cmake -DQT_QMAKE_EXECUTABLE=~/Development/QtSDK/Desktop/Qt/4.8.2/gcc/bin/qmake ../..
+
Other things will later go wrong too, especially when making the application bundle.
+
</ref>...
+
  
 
  $ cmake ../..
 
  $ cmake ../..
Line 91: Line 68:
  
 
  $ make
 
  $ make
 +
 +
=== Testing ===
 +
 +
Optionnaly, we test our build
 +
 +
$ make tests
  
 
== Packaging ==
 
== Packaging ==
Line 101: Line 84:
  
 
  $ make install
 
  $ make install
  $ make macosx_bundle
+
  $ make mac_app
 +
 
 +
The mac_app target includes a python script that makes use of otool and install_name_tool to:
 +
 
 +
# read the link dependencies of Stellarium.app/Contents/MacOS/stellarium,
 +
# copy those dependencies into the app (.frameworks and .dylibs),
 +
# recurse on those copied-in dependencies, stopping at a point where system libraries are called for.
  
The macosx_bundle target includes a perl script that makes use of otool and install_name_tool to:
+
== Creating DMG (Apple Disk Image) ==
  
# read the link dependencies of Stellarium.app/Contents/MacOS/stellarium
+
$ mkdir Stellarium
# copy those dependencies into the app (.frameworks and .dylibs)
+
$ cp -r Stellarium.app Stellarium
# recurse on those copied-in dependencies, stopping at a point where system libraries are called for
+
$ hdiutil create -format UDZO -srcfolder Stellarium Stellarium.dmg
  
 
== We recommend Qt Creator ==
 
== We recommend Qt Creator ==

Latest revision as of 17:29, 19 August 2015

This document describes how to build Stellarium from sources on Mac OS X. This process ought to improve over time.

The set of instructions was written for the 0.13.0 and later releases and using an Intel machine with Mountain Lion (10.8) or later, including Yosemite (10.10.5 at the moment). No universal builds were made since a lot of time (version 0.11.3, 2012-07-31).

Contents

[edit] Prepare Mac OS X to build Stellarium

[edit] First step: Install Developer Tools and Qt

  1. Install the latest version of Apple's Developer Tools: https://developer.apple.com/xcode/
  2. Install the latest stable version of Qt5 (5.4.2 at the moment): http://www.qt.io/download-open-source/ (offline installer)
  3. Add Qt5 to your PATH environment variable, adding to your .bash_profile file the following line: export PATH=~/Qt/5.4/clang_64/bin:$PATH

[edit] Second step: Install CMake and Bazaar

You need some tools to build Stellarium on OS X. This tools are CMake and Bazaar. There are (at least) two simple options to install these tools on OS X. Choose only one of them (HomeBrew or MacPorts).

[edit] Option 1: With HomeBrew

Simpler, lighter and safer (doesn't need sudo) than MacPorts.

  1. Install HomeBrew: http://brew.sh
  2. Install CMake: $ brew install cmake
  3. Install Bazaar: $ brew install bazaar
  4. (optional) Install (and link) Gettext: $ brew install gettext; brew link gettext --force

[edit] Option 2: With MacPorts

  1. Install MacPorts: http://www.macports.org/install.php
  2. Install CMake: $ sudo port install cmake
  3. Install Bazaar: $ sudo port install bzr

[edit] Last step: Restart terminal session

Don't forget to restart your terminal session, so that your new PATH setting is taken in account.

[edit] Building Stellarium itself

Create a build directory with your favorite shell (the following directory is just an example, you can pick any name and path you want)

$ mkdir ~/Development
$ cd ~/Development

[edit] Getting Stellarium source code

In that directory checkout the sources with the bzr command

$ bzr branch lp:stellarium stellarium

For more details, see the Bazaar checkout instructions.

If you have already done it once, you have just to update your copy using this bzr command

$ bzr pull

[edit] Time to compile Stellarium

We setup the build directory

$ cd stellarium 
$ mkdir -p builds/macosx
$ cd builds/macosx

We run cmake...

$ cmake ../..

... and compile

$ make

[edit] Testing

Optionnaly, we test our build

$ make tests

[edit] Packaging

IMPORTANT: you should delete or move aside the old Stellarium.app before each new build:

$ rm -r Stellarium.app/

Then make the Mac OS X application:

$ make install
$ make mac_app

The mac_app target includes a python script that makes use of otool and install_name_tool to:

  1. read the link dependencies of Stellarium.app/Contents/MacOS/stellarium,
  2. copy those dependencies into the app (.frameworks and .dylibs),
  3. recurse on those copied-in dependencies, stopping at a point where system libraries are called for.

[edit] Creating DMG (Apple Disk Image)

$ mkdir Stellarium
$ cp -r Stellarium.app Stellarium
$ hdiutil create -format UDZO -srcfolder Stellarium Stellarium.dmg

[edit] We recommend Qt Creator

The core group of developers of stellarium uses QtCreator as main IDE, its integration with Qt and the possibility of having a consistent tool through different platforms makes it the most suitable option for our goals.

[edit] Troubleshooting

All kinds of things might go wrong!

We will write here the most frequent problems and the possible solutions found by the developers.

[edit] References

Personal tools
Namespaces
Variants
Actions
in this wiki
other languages
Toolbox