Compilation on Mac OS X

(Difference between revisions)
Jump to: navigation, search
Line 12: Line 12:
# MacPorts installed. See [].
# MacPorts installed. See [].
'''Note:''' As of this writing 2007-12-29, the compilation '''doesn't work''' on Mac OS X 10.5.x (Leopard). A solution is still needed for correcting this. When trying to compile Stellarium on Leopard you'll get errors in ''stellarium/stellarium/src/Telescope.cpp'', with ''invalid conversion from 'const fd_set*' to 'fd_set*'' errors. There is a [ proposed patch] in the tracker.
'''Note:''' As of revision 2712, a [ patch] by [[User:Raimue|Rainer Mueller]] fixes the compilation problems with ''stellarium/stellarium/src/Telescope.cpp'' on Mac OS X 10.5.x (Leopard).
=== With Fink ===
=== With Fink ===

Revision as of 15:44, 15 January 2008

This document attempts to describe how to build Stellarium for Macosx from source, post version 0.9.0. It tries to list all the dependencies and steps. This process ought to improve over time. It largely supersedes Building universal Stellarium 0.8.1 on an Intel Mac.

IMPORTANT: These instructions currently build Stellarium that is not a universal binary, it is specific to the machine (PPC or Intel) that it was made on. Universal binaries buildable by all is yet a goal for the Macosx port. The built Stellarium is also currently dependent on how and where libraries are installed on your system: if you've got some interesting setup, a build you make with it might not run so good on other macs with less interesting setups.



Before the list of build dependencies, there are some minimum system requirements to follow these instructions:

  1. Mac OS X 10.4, as most recent as possible. As of this writing 2007-12-29, 10.4.11 is available and known to work for both PPC and Intel. Earlier versions might work, but I don't know, and more steps might be needed. Note also that 10.4.7 should be avoided at all costs.
  2. Xcode as recent as possible. This author has Xcode 2.4.1. See [1]. Earlier versions might work, but I don't know, and more steps might be needed.
  3. fink installed, preferably in the default /sw. See [2] or
  4. MacPorts installed. See [3].

Note: As of revision 2712, a patch by Rainer Mueller fixes the compilation problems with stellarium/stellarium/src/Telescope.cpp on Mac OS X 10.5.x (Leopard).

With Fink

From the list of build dependencies, we need to actually *think* about only the following:

  1. Cmake, from [4]
  2. libpng, get this via fink with "fink install libpng3" (you might need "sudo" in front of that)
  3. libjpeg, get this via fink with "fink install libjpeg" (likewise)
  4. libboost, get this via fink with "fink install boost1.33" (1.33 was most current as of this writing)
  5. libsdl, this can also be finked with "fink install sdl-shlibs"
  6. Qt 4.3, go out to [5], look for their open-source downloads of Qt/Mac. This should be installed the default way.
  7. SDL_mixer, if and only if you want audio. This I had to compile especially (get from [[6]]), the fink build had some hidden dependencies (timidity, for instance, wants things in /usr/local...) that I removed with this configure for SDL_mixer:
 CPPFLAGS="-I/sw/include -I/sw/include/ogg" LDFLAGS="-L/sw/lib" ./configure --prefix=/sw --disable-music-midi --disable-music-timidity-midi --disable-music-ogg-shared --disable-music-mp3-shared --enable-music-ogg --enable-music-mp3
  1. subversion, here I found fink's svn not so good for 1.4.3, I had to resort to [7]. Another option is this package by Martin Ott, Developer of CodingMonkeys

With MacPorts

Just type this one command in Terminal

   sudo port install subversion cmake boost libsdl_mixer libsdl qt4-mac freetype

Advantage of this setup is that you use the macports cmake, so you dont have to manually specify include-dirs and paths for qt, sdl and fonts (see below).


Make a directory


And in that directory in your favorite shell, utter the svn command to check out the source:

 svn co stellarium

Now things start to look like the linux instructions some:

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

The process now differs with Fink and MacPorts (easier with MacPorts)

With Fink

Now the moment of truth: the cmake command (i'm in bash!):

 SDL_INCLUDE_DIR=/sw/include/SDL cmake -G "Unix Makefiles"  ../..

This says: set the environment variable SDL_INCLUDE_DIR to /sw/include/SDL, use the "Unix Makefiles" generator of cmake. If it doesn't find Qt, you should maybe append the path to Qt to your shell path:

 export PATH=/usr/local/Trolltech/Qt-4.3.1/bin:$PATH

It will think about that for a bit, and then complain:

 CMake Error: Error in cmake code at
 MESSAGE Could not find the FreeType2 library and header files.
 Current CMake stack: /Users/Shared/stellarium/stellarium/CMakeLists.txt;/usr/share/cmake-2.4/Modules/CMakeCInformation.cmake;/usr/share/cmake-2.4/Modules/CMakeCXXInformation.cmake;/Users/Shared/stellarium/stellarium/cmake/FindFreeType2.cmake

This is all right: cmake never seems to be able to correctly find freetype2 here on the mac. You are still in builds/macosx. In this directory now there should be a CMakeCache.txt file. Edit that file, and find the line:


and change it to read:


Now utter the same cmake command a second time, and it should think some more, and end up with:

 -- Configuring done
 -- Generating done
 -- Build files have been written to: /Users/Shared/stellarium/stellarium/builds/macosx

Now we can perform the build itself, two steps:

 make install
 make macosx_bundle

Now up in /Users/Shared/stellarium, you ought to see a, ready to run!

With MacPorts

Type the following command in your terminal window

 cmake -G "Unix Makefiles"  ../..

This says: use the "Unix Makefiles" generator of cmake. It should say

 -- Configuring done
 -- Generating done
 -- Build files have been written to: /Users/Shared/stellarium/stellarium/builds/macosx

Then perform the build itself, three steps:

 make install
 make macosx_bundle

Now up in /Users/Shared/stellarium, you ought to see a, ready to run!


As of about r2600, a new sub-step has been added to the macosx_bundle target: a perl script that makes use of otool and install_name_tool to:

  1. read the link dependencies of libstelMain.dylib and 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

This seems to work for making a relocatable Making a universal build from here is a matter of taking an intel and a ppc and merging them appropriately.

I've found that making a universal app directly via cmake to be troublesome if not impossible. Any insights appreciated!


You can check to see if the source code has been updated on the server at any time by going in a terminal window to


And entering the command

 svn -u status

Any file that it mentions is either changed locally, or changed on the server (svn help status for details of the output of this command). Unless you are working on the source code yourself, anything mentioned is an update. You can update from this directory also with

 svn update

IMPORTANT: you should delete or move aside the old /Users/Shared/stellarium/ before each new build.

Why Not Xcode?

Cmake has an Xcode generator (as opposed to "Unix Makefiles"), but I haven't had good luck with it. The xcodeproj files generated are not readable by the xcode here. I don't know if that is a fault of my environment (which I do not think is special), or something else.

Cmake generally has made this whole compilation process on the mac both more repeatable, and more like the other platforms (or, at least, more like the unix and such...). This is a Good Thing.


All kinds of things might go wrong!

  1. if the cmake or the build complains about a missing library, it might need installation. Start with fink.
  2. if the compilation breaks on some code, it may be that the developers are in the middle of something, and come back in a svn revision or so.
  3. anything else I haven't remembered or encountered!

Loadable Module Support

I was able to get loadable module support working, and have submitted patches for the CMakeLists.txt files in StellaGui and HelloStelModule. These build straightforwardly:

  1. edit the top-level CMakeLists.txt file to point to where your real stellarium source and build directories are.
  2. make builds/macosx and cd to it
  3. run cmake and make:
 cmake -G "Unix Makefiles"  ../..
 make install

and you should have StellaGui or HelloStelModule as a directory in builds/macosx, which you can copy to ~/Library/Preferences/Stellarium/modules/ (you may have to make that directory).

To Do

  • make the build a universal binary (somehow...)
  •  ???
Personal tools
in this wiki
other languages