Before the list of [[Build Dependencies|build dependencies]], there are some minimum system requirements to follow these instructions:

Before the list of [[Build Dependencies|build dependencies]], there are some minimum system requirements to follow these instructions:

−

# Macosx 10.4, as most recent as possible. As of this writing 2007-07-02, 10.4.10 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.

+

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

# Xcode as recent as possible. This author has Xcode 2.4.1. See [http://developer.apple.com/]. Earlier versions might work, but I don't know, and more steps might be needed.

# Xcode as recent as possible. This author has Xcode 2.4.1. See [http://developer.apple.com/]. Earlier versions might work, but I don't know, and more steps might be needed.

# fink installed, preferably in the default /sw. See [http://fink.sf.net/] or

# fink installed, preferably in the default /sw. See [http://fink.sf.net/] or

# MacPorts installed. See [http://www.macports.org/].

# MacPorts installed. See [http://www.macports.org/].

+

+

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

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

+

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

== Building ==

== Building ==

Revision as of 11:01, 29 December 2007

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.

Contents

Dependencies

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

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.

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.

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.

With fink

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

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:

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
/Users/Shared/stellarium/stellarium/cmake/FindFreeType2.cmake:41:
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:

FreeType2_INCLUDE_DIR:PATH=FreeType2_INCLUDE_DIR-NOTFOUND

and change it to read:

FreeType2_INCLUDE_DIR:PATH=/usr/X11R6/include/freetype2

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

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

Packaging

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:

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

This seems to work for making a relocatable Stellarium.app. 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!

Updating

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

/Users/Shared/stellarium/stellarium

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/Stellarium.app 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.

Troubleshooting

All kinds of things might go wrong!

if the cmake or the build complains about a missing library, it might need installation. Start with fink.

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.

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:

edit the top-level CMakeLists.txt file to point to where your real stellarium source and build directories are.

make builds/macosx and cd to it

run cmake and make:

cmake -G "Unix Makefiles" ../..
make
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).