Compilation on Mac OS X

(Difference between revisions)
Jump to: navigation, search
(Time to compile stellarium)
m (Mac OS X version update)
(43 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This document attempts to describe how to build Stellarium from sources on MacOSX. 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 to be validated for other versions.
+
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 release and using an Intel machine with Mountain Lion (10.8) or later, including Mavericks (10.9.2 at the moment).
  
 
== Prepare Mac OS X to build Stellarium ==   
 
== Prepare Mac OS X to build Stellarium ==   
  
You need a machine with Mac OS X 10.4 (latest version 10.4.11) or later<ref>Since version 0.10.6 you need Mac OS X 10.5 or later.</ref><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.</ref>
+
'''Note: if you need an universal binary, see section [[#Compiling dependencies to build an universal binary|Compiling dependencies to build an universal binary]] below.'''
  
 
# 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: http://developer.apple.com/technology/xcode.html
# Install the latest version of cmake: http://www.cmake.org/cmake/resources/software.html
+
# Install the latest stable version of Qt5 from the dmg (5.2.1 at the moment): http://qt-project.org/downloads#qt-lib ([http://download.qt-project.org/official_releases/qt/5.2/5.2.1/qt-opensource-mac-x64-clang-5.2.1.dmg direct download])
# Install the latest version of Qt: Framework from the dmg (4.6.2 at the time these instructions were written) http://qt.nokia.com/downloads
+
 
# Install macports: http://www.macports.org/install.php
 
# Install macports: http://www.macports.org/install.php
# Install bazaar making use of macports:
+
# Install cmake using macports: <code>$ sudo port install cmake</code>
 +
# Install bazaar using macports: <code>$ sudo port install bzr</code>
 +
# Add Qt5 to your PATH environment variable, adding to your ''.bash_profile'' file the following line: <code>export PATH=~/Qt5.2.1/5.2.1/clang_64/bin:$PATH</code>
  
  $ sudo port install bzr
+
Don't forget to restart your terminal session, so that your new PATH setting is taken in account.
  
Note:
+
== Building Stellarium itself ==
  
For Mac OS X there are two different versions of Qt:
+
Create a build directory with your favorite shell (the following directory is just an example, you can pick any name and path you want)
  
* Carbon version: Default download and recommended option. It works for Mac OS X 10.5/4/3, and both Intel and PPC architectures. Install this one if you want to create universal binaries
+
$ mkdir ~/Development
 +
$ cd ~/Development
  
* Cocoa version: Exclusively for Intel architecture and Mac OS X 10.5 and later. You can use this if you aren't going to create universal binaries.
+
=== Getting Stellarium source code ===
  
== Compiling dependencies to build an universal binary ==
+
In that directory checkout the sources with the bzr command
  
We have to compile the dependencies with special flags to be able to generate 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]]
+
$ bzr branch lp:stellarium stellarium
  
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:
+
For more details, see [[Bzr checkout|the Bazaar checkout instructions]].
  
a. We want to generate a single binary for both intel and ppc architectures so:
+
If you have already done it once, you have just to update your copy using this bzr command
  
-arch i386 -arch ppc
+
$ bzr pull
  
b. We want to link with the old framework and system libraries:
+
=== Time to compile Stellarium ===
  
-mmacosx-version-min=10.4
+
We setup the build directory
-isysroot /Developer/SDKs/MacOSX10.4u.sdk/ (Not sure if this is really needed)
+
  
=== Compiling dependencies ===
+
$ cd stellarium
 +
$ mkdir -p builds/macosx
 +
$ cd builds/macosx
  
- 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:
+
[[Configuring Build Options|We run cmake]]...
  
  $ ./configure --prefix=/usr CFLAGS='-arch i386 -arch ppc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/'
+
$ cmake ../..
  $ 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:
+
... and compile
  
  $ ./configure CFLAGS='-arch i386 -arch ppc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/'
+
$ make
  $ 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:
+
=== Testing ===
  
* Gcc 4.2 is used by default. Configure with -platform macx-g++40 to select 4.0.
+
Optionnaly, we test our build
* 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.
+
$ make tests
 
+
== 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)
+
== Packaging ==
  
$ mkdir ~/Development
+
'''IMPORTANT''': you should delete or move aside the old Stellarium.app before each new build:
$ cd ~/Development
+
  
And in that directory checkout the sources with the bzr command
+
$ rm -r Stellarium.app/
  
$ bzr branch lp:stellarium stellarium
+
Then make the Mac OS X application:
  
For more details, see [[Bzr checkout|the Bazaar checkout instructions]].
+
$ make install
 +
$ make mac_app
  
=== Time to compile stellarium ===
+
The mac_app target includes a python script that makes use of otool and install_name_tool to:
  
We setup the build directory
+
# 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.
  
$ cd stellarium
+
== We recommend Qt Creator ==
$ mkdir -p builds/macosx
+
$ cd builds/macosx
+
  
[[Configuring Build Options|We run cmake]]...
+
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.
  
$ cmake ../..
+
== Compiling dependencies to build an universal binary ==
  
You'll have to pass location of your QtSDK instllation, e.g.
+
'''Note: This step is needed only if you need an universal binary. If you don't intend to create an universal package you can ignore this and refer to section [[#Building Stellarium itself|Building Stellarium itself]].'''
  
$ cmake -DQT_QMAKE_EXECUTABLE=~/Development/QtSDK/Desktop/Qt/4.8.1/gcc/bin/qmake ../..
+
'''Note: This step is potentially outdated. If you know how to update it, feel free to do it.'''
  
if your installation complains that it didn't found Qt with such an error message
+
We have to compile the dependencies with special flags to be able to generate an universal binary.
  
  CMake Error at /Applications/CMake 2.8-9.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:97 (MESSAGE):
+
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:
    Could NOT find Qt4 (missing: QT_QMAKE_EXECUTABLE QT_MOC_EXECUTABLE
+
    QT_RCC_EXECUTABLE QT_UIC_EXECUTABLE QT_INCLUDE_DIR QT_LIBRARY_DIR
+
    QT_QTCORE_LIBRARY) (Required is at least version "4.6.2")
+
  Call Stack (most recent call first):
+
    /Applications/CMake 2.8-9.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:288 (_FPHSA_FAILURE_MESSAGE)
+
    /Applications/CMake 2.8-9.app/Contents/share/cmake-2.8/Modules/FindQt4.cmake:1200 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
+
    CMakeLists.txt:248 (FIND_PACKAGE)
+
  
... and compile
+
a. We want to generate a single binary for both intel and ppc architectures so:
  
$ make
+
-arch i386 -arch ppc
  
== Packaging ==
+
b. We want to link with the old framework and system libraries:
  
$ make install
+
-mmacosx-version-min=10.4
$ make macosx_bundle
+
-isysroot /Developer/SDKs/MacOSX10.4u.sdk/ (Not sure if this is really needed)
  
'''IMPORTANT''': you should delete or move aside the old /Users/Shared/stellarium/Stellarium.app before each new build.
+
=== Compiling dependencies ===
  
The macosx_bundle target includes a perl script that makes use of otool and install_name_tool to:
+
- 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:
  
# read the link dependencies of Stellarium.app/Contents/MacOS/stellarium
+
  $ ./configure --prefix=/usr CFLAGS='-arch i386 -arch ppc -mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/'
# copy those dependencies into the app (.frameworks and .dylibs)
+
  $ make
# recurse on those copied-in dependencies, stopping at a point where system libraries are called for
+
  $ make install
  
== We recommend Qt Creator ==
+
- 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:
  
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.
+
  $ ./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.
  
 
== Troubleshooting ==
 
== Troubleshooting ==

Revision as of 10:00, 9 March 2014

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 release and using an Intel machine with Mountain Lion (10.8) or later, including Mavericks (10.9.2 at the moment).

Contents

Prepare Mac OS X to build Stellarium

Note: if you need an universal binary, see section Compiling dependencies to build an universal binary below.

  1. Install the latest version of Apple's Developer Tools: http://developer.apple.com/technology/xcode.html
  2. Install the latest stable version of Qt5 from the dmg (5.2.1 at the moment): http://qt-project.org/downloads#qt-lib (direct download)
  3. Install macports: http://www.macports.org/install.php
  4. Install cmake using macports: $ sudo port install cmake
  5. Install bazaar using macports: $ sudo port install bzr
  6. Add Qt5 to your PATH environment variable, adding to your .bash_profile file the following line: export PATH=~/Qt5.2.1/5.2.1/clang_64/bin:$PATH

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

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

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

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

Testing

Optionnaly, we test our build

$ make tests

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.

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.

Compiling dependencies to build an universal binary

Note: This step is needed only if you need an universal binary. If you don't intend to create an universal package you can ignore this and refer to section Building Stellarium itself.

Note: This step is potentially outdated. If you know how to update it, feel free to do it.

We have to compile the dependencies with special flags to be able to generate an universal binary.

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:

a. We want to generate a single binary for both intel and ppc architectures so:

-arch i386 -arch ppc

b. We want to link with the old framework and system libraries:

-mmacosx-version-min=10.4 -isysroot /Developer/SDKs/MacOSX10.4u.sdk/ (Not sure if this is really needed)

Compiling dependencies

- 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.

Troubleshooting

All kinds of things might go wrong!

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

References

Personal tools
Namespaces
Variants
Actions
in this wiki
other languages
Toolbox