Compilation on Mac OS X

(Difference between revisions)
Jump to: navigation, search
(Dependencies)
(Building)
Line 42: Line 42:
 
And in that directory in your favorite shell, utter the svn command to check out the source:
 
And in that directory in your favorite shell, utter the svn command to check out the source:
  
<nowiki>svn co https://stellarium.svn.sourceforge.net/svnroot/stellarium/trunk/stellarium stellarium</nowiki>
+
  <nowiki>svn co https://stellarium.svn.sourceforge.net/svnroot/stellarium/trunk/stellarium stellarium</nowiki>
  
 
Now things start to look like the [[Compilation on Linux|linux instructions]] some:
 
Now things start to look like the [[Compilation on Linux|linux instructions]] some:
Line 49: Line 49:
 
   mkdir -p builds/macosx
 
   mkdir -p builds/macosx
 
   cd 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!):
 
Now the moment of truth: the cmake command (i'm in bash!):
Line 80: Line 84:
  
 
Now we can perform the build itself, two steps:
 
Now we can perform the build itself, two steps:
 +
 +
  make
 +
  make install
 +
  make macosx_bundle
 +
 +
Now up in /Users/Shared/stellarium, you ought to see a Stellarium.app, 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
 
   make

Revision as of 21:11, 29 October 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:

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

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

Building

Make a directory

 /Users/Shared/stellarium

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

 svn co https://stellarium.svn.sourceforge.net/svnroot/stellarium/trunk/stellarium 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
 /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:

 -- 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
 make install
 make macosx_bundle

Now up in /Users/Shared/stellarium, you ought to see a Stellarium.app, 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
 make install
 make macosx_bundle

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

Important note

With current revision (rev 2567) of source code (as of 2007-10-24), the app will crash when launched from the Finder. To get it work, you'll have to launch it from the terminal:

 /Users/Shared/stellarium/Stellarium.app/Contents/MacOS/stellarium

Or you can fix where the app looks for the dynamic lib, like this:

 cd /Users/Shared/stellarium/Stellarium.app/Contents/MacOS/
 install_name_tool -change libstelMain.dylib @executable_path/libstelMain.dylib stellarium

This way the app should launch correctly from the Finder. --Mina 12:02, 24 October 2007 (PDT)

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!

  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
 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
Namespaces
Variants
Actions
in this wiki
other languages
Toolbox