Compilation on Mac OS X

From Stellarium Wiki
(Redirected from Compilation on Macosx)
Jump to: navigation, search

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 El Capitan (10.11.x) and macOS Sierra (10.12.6 at the moment).


Prepare Mac OS X to build Stellarium

First step: Install Apple Developer Tools

  1. Install the latest version of Apple's Developer Tools:

Second step: Install Qt

Option 1: Using the distribution from the Qt Company

  1. Install the latest stable version of Qt5.10 (5.10.0 at the moment): (offline installer)
  2. Add Qt5 to your PATH environment variable, adding to your .bash_profile file the following line: export PATH=~/Qt/5.10/clang_64/bin:$PATH

Option 2: With HomeBrew

Alternatively, you may install Qt with HomeBrew, if you intend to continue the compilation with it (next steps).

  1. Install HomeBrew:
  2. Install latest Qt: $ brew install qt
  3. Add Qt to your PATH environment variable, adding to your .bash_profile file the following line: export PATH=/usr/local/opt/qt/bin:$PATH

Third step: Install CMake and git

You need some tools to build Stellarium on OS X. These 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).

Option 1: With HomeBrew

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

  1. If not already done, install HomeBrew:
  2. Install CMake: $ brew install cmake
  3. Install Git: $ brew install git
  4. (optional) Install (and link) Gettext: $ brew install gettext; brew link gettext --force

Option 2: With MacPorts

  1. Install MacPorts:
  2. Install CMake: $ sudo port install cmake
  3. Install Git: $ sudo port install git

Last step: Restart terminal session

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 git command

$ git clone

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

$ git pull

Time to compile Stellarium

We setup the build directory

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

We run cmake (see other configuration build options here) ...

$ cmake ../..

... or, if we want a release build (instead of a debug one), ...

$ cmake -DCMAKE_BUILD_TYPE=Release ../..

... and we compile

$ make


Optionnaly, we test our build

$ make tests


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

$ rm -r

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

Creating DMG (Apple Disk Image)

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

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.


All kinds of things might go wrong!

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

Missing Qt Packages

If during the cmake process, you receive an error like:

CMake Error at CMakeLists.txt:271 (FIND_PACKAGE):
  By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Qt5Core", but
  CMake did not find one.

  Could not find a package configuration file provided by "Qt5Core" with any
  of the following names:


  Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
  "Qt5Core_DIR" to a directory containing one of the above files.  If
  "Qt5Core" provides a separate development package or SDK, be sure it has
  been installed.

Then set CMAKE_PREFIX_PATH to the location of the your Qt install, something like ~/Qt/5.7/clang_64:

$ export CMAKE_PREFIX_PATH=~/Qt/5.7/clang_64


Personal tools
in this wiki
other languages