Building universal Stellarium 0.8.1 on an Intel Mac

From Stellarium Wiki
(Difference between revisions)
Jump to: navigation, search
(Fixing some quirks)
 
(24 intermediate revisions by 5 users not shown)
Line 3: Line 3:
 
==What you need==
 
==What you need==
  
*1) Stellarium 0.8.1 sources that you can download [http://sourceforge.net/project/showfiles.php?group_id=48857 here]. They are in the file '''stellarium-0.8.1.tar.gz'''
+
*1) The source code for Stellarium 0.8.1. You can check them out of CVS (see the source forge pages for details) or simply download a source tarball from [http://sourceforge.net/project/showfiles.php?group_id=48857 here]. They are in the file '''stellarium-0.8.1.tar.gz''' Note that building from the tarball is easier than building from CVS.
 
*2) A ready made Xcode project for building Stellarium on Mac OS X. You can download the file '''macosx-xcode.tar.gz''' containing such project from [http://stellarium.cvs.sourceforge.net/stellarium/stellarium/macosx-xcode.tar.gz?view=log here]. I choose revision 1.4.
 
*2) A ready made Xcode project for building Stellarium on Mac OS X. You can download the file '''macosx-xcode.tar.gz''' containing such project from [http://stellarium.cvs.sourceforge.net/stellarium/stellarium/macosx-xcode.tar.gz?view=log here]. I choose revision 1.4.
*3) An Intel Mac (a PowerPC Mac should make it too) with developer tools installed. I used Xcode 2.4.
+
*3) An Intel or PPC Mac with a recent version of the developer tools installed. I used Xcode 2.4.
 +
*4) If you are building from CVS, you will need to install [http://fink.sourceforge.net Fink] and several packages; if you are building from a tarball, Fink is optional.
  
 
==Project layout==
 
==Project layout==
 
After extracting the archives you should have two folders, one named '''stellarium-0.8.1''' and the other named '''macosx'''. Make sure to place the '''macosx''' folder into the '''stellarium-0.8.1''' folder, as this is essential for successful project building.
 
After extracting the archives you should have two folders, one named '''stellarium-0.8.1''' and the other named '''macosx'''. Make sure to place the '''macosx''' folder into the '''stellarium-0.8.1''' folder, as this is essential for successful project building.
  
==Target settings==
+
Step by Step Instructions:
If you want to build an universal binary you have to modify the build settings of the '''Stellarium''' target, since they target a PPC architecture.  
+
 
Open the '''Stellarium''' target properties, choose the build tab and add the i386 architecture to the Architectures setting (double click on the row and check the i386 checkbox).
+
*1) Open a terminal window. These instructions will assume that you know how to use Terminal and have some familiarity with UNIX commands.
This must be done for all configurations for which you want to build a universal binary.
+
 
 +
*2) cd to the directory you saved the stellarium download.
 +
 
 +
*3) type the following commands:
 +
tar zxf stellarium-0.8.1.tar.gz
 +
cd stellarium-0.8.1
 +
tar zxf ../macosx-xcode.tar.gz
  
 
==Fixing some quirks==
 
==Fixing some quirks==
At this point one would expect to build the project, but after some work the compiler complains and stops the build.
+
At this point one would expect to build the project, but after some work the compiler complains and stops the build. Instead, you must first perform some of the steps done to build the Linux version of Stellarium. These steps will differ depending on whether or not you have [http://fink.sourceforge.net/download/ Fink] installed.
These are the code changes I had to do to successfully build the project:
+
  
*1) There is a missing '''libgnuintl.h''' header file. This file should probably be one of the outputs of the configure script in the '''stellarium-0.8.1''' folder. On my machine this script aborts prematurely and I didn't manage to make it work. As a workaround you can copy the '''libgnuintl.h.in''' file in the '''stellarium-0.8.1/intl''' folder to a file named '''libgnuintl.h''' in the same folder and replace in it the string '''@HAVE_POSIX_PRINTF@''' with the string '''HAVE_POSIX_PRINTF'''. I don't know if doing this is correct but it seems to work!
+
==With Fink==
 +
These steps actually seem more complicated than building without Fink, but they are actually needed if you build from a CVS checkout instead of a tar ball.
  
*2) There is a #include to change in '''gettext.h''':
+
*0) Make sure you have the SDL and SDL-mixer packages installed. We will actually be using the version of SDL-mixer that is included with the macosx-xcode.tar.gz file, but we need other SDL-mixer files to get '''configure''' to run correctly.  
# include <libintl.h>
+
  
must be changed to:
+
*1) You need to run configure just as if you were doing a Linux build. To get configure to work, you must set some environment variables and create a symbolic link. In the stellarium directory, in the terminal application, paste the following commands:
  
  #ifdef _LIBC
+
  LDFLAGS="$LDFLAGS -L$PWD/macosx/Frameworks"
  # include <libintl.h>
+
  CPPFLAGS="$CPPFLAGS -I$PWD/macosx/Headers"
  #else
+
  CPPFLAGS="$CPPFLAGS -I$PWD/macosx/Frameworks/SDL.framework/Headers"
  # include "libgnuintl.h"
+
  CPPFLAGS="$CPPFLAGS -I$PWD/macosx/Frameworks/SDL_mixer.framework/Headers"
  #endif
+
  export LDFLAGS CPPFLAGS
 +
export PATH=/usr/X11R6/bin:$PATH
 +
ln -s $PWD/macosx/Frameworks ../Frameworks
 +
cd macosx/Frameworks
 +
ln -s freetype.dylib libfreetype.dylib
 +
cd ../..
  
*3) '''translator.cpp''' contains a Mac OS X specific macro, in the reload method, that misses a right brace:
+
*2) Now you are ready to "configure" Stellarium. If you are building from CVS, type the command:
 +
./autogen.sh
 +
*2a) In both cases, you must next type the command:
 +
./configure
 +
 
 +
*3) There are missing '''libgnuintl.h''' and '''libintl.h''' header files. To make these files:
 +
cd intl
 +
make libintl.h
 +
cd ..
 +
 
 +
*3a) If you are building from a CVS checkout, you will now need to do these steps:
 +
cd po
 +
make
 +
cd ..
 +
 
 +
*4) At this point, you can delete the ../Frameworks file you created in the first step.
 +
rm -f ../Frameworks
 +
 
 +
==Without Fink==
 +
If you don't want to use Fink and install SDL libraries, then do as follows.
 +
 
 +
*1) Modify the '''configure''' script in '''stellarium-0.8.1''' directory so that the following lines:
 +
 
 +
case "$host" in
 +
*-*-mingw32)
 +
;;
 +
*-*-cygwin)
 +
;;
 +
*)
 +
SDL_VERSION=1.2.0
 +
 
 +
become:
 +
 
 +
case "$host" in
 +
*-*-mingw32)
 +
;;
 +
*-*-cygwin)
 +
;;
 +
*-*-darwin*)  <---- '''ADD THIS LINE'''
 +
;;            <---- '''ADD THIS LINE'''
 +
*)
 +
SDL_VERSION=1.2.0
 +
This skips SDL checks in '''configure''', since SDL libraries and headers are already configured in the Xcode project.
 +
 
 +
*2) Follow steps 1 to 4 of building '''With Fink'''.
 +
 
 +
==Fixing Bugs==
 +
*1) '''src/translator.cpp''' contains a Mac OS X specific macro, in the reload method, where a right brace is missing. This causes the compile to fail. Load the file in an editor or xcode and add one line:
  
 
  #ifndef MACOSX
 
  #ifndef MACOSX
Line 52: Line 110:
 
  {
 
  {
 
  snprintf(envstr, 25, "LANG=%s", langName.c_str());
 
  snprintf(envstr, 25, "LANG=%s", langName.c_str());
  } <------- MISSING, MUST BE ADDED
+
  } '''<------- MISSING, MUST BE ADDED'''
 
  #endif
 
  #endif
 +
 +
==Target settings==
 +
If you want to build an universal binary you have to modify the build settings of the '''Stellarium''' target, since they are for a PPC architecture.
 +
Open the '''Stellarium''' target properties, choose the build tab and add the i386 architecture to the Architectures setting (double click on the row and check the i386 checkbox).
 +
 +
This must be done for all configurations for which you want to build a universal binary.
 +
 +
==Run and enjoy==
 +
After following the previous steps you should be able to build the project and run Stellarium natively on a Intel Mac.
 +
On my machine (Core 2 Duo 2.16 Mhz and NVIDIA 7600 GT) the fps averages 35-45 versus 8-9 frames of the PowerPC interpreted version.
 +
 +
==Caveat==
 +
If you have have an ATI graphic card it is perfectly possible that Stellarium doesn't work anyway. I read somewhere (don't remember exactly) that there is an OpenGL bug in the ATI driver, and it could be the reason why Stellarium doesn't work on MacBook Pro or other Intel Macs with ATI cards.
 +
 +
In that case you must be patient and wait for MacOS 10.4.8, where it will be likely fixed.
 +
 +
[[Category:Development]]

Latest revision as of 13:53, 2 December 2008

What follows is a quick overview of what I did to build a universal application from Stellarium 0.8.1 sources on an Intel Mac.

Contents

[edit] What you need

  • 1) The source code for Stellarium 0.8.1. You can check them out of CVS (see the source forge pages for details) or simply download a source tarball from here. They are in the file stellarium-0.8.1.tar.gz Note that building from the tarball is easier than building from CVS.
  • 2) A ready made Xcode project for building Stellarium on Mac OS X. You can download the file macosx-xcode.tar.gz containing such project from here. I choose revision 1.4.
  • 3) An Intel or PPC Mac with a recent version of the developer tools installed. I used Xcode 2.4.
  • 4) If you are building from CVS, you will need to install Fink and several packages; if you are building from a tarball, Fink is optional.

[edit] Project layout

After extracting the archives you should have two folders, one named stellarium-0.8.1 and the other named macosx. Make sure to place the macosx folder into the stellarium-0.8.1 folder, as this is essential for successful project building.

Step by Step Instructions:

  • 1) Open a terminal window. These instructions will assume that you know how to use Terminal and have some familiarity with UNIX commands.
  • 2) cd to the directory you saved the stellarium download.
  • 3) type the following commands:
tar zxf stellarium-0.8.1.tar.gz
cd stellarium-0.8.1
tar zxf ../macosx-xcode.tar.gz

[edit] Fixing some quirks

At this point one would expect to build the project, but after some work the compiler complains and stops the build. Instead, you must first perform some of the steps done to build the Linux version of Stellarium. These steps will differ depending on whether or not you have Fink installed.

[edit] With Fink

These steps actually seem more complicated than building without Fink, but they are actually needed if you build from a CVS checkout instead of a tar ball.

  • 0) Make sure you have the SDL and SDL-mixer packages installed. We will actually be using the version of SDL-mixer that is included with the macosx-xcode.tar.gz file, but we need other SDL-mixer files to get configure to run correctly.
  • 1) You need to run configure just as if you were doing a Linux build. To get configure to work, you must set some environment variables and create a symbolic link. In the stellarium directory, in the terminal application, paste the following commands:
LDFLAGS="$LDFLAGS -L$PWD/macosx/Frameworks"
CPPFLAGS="$CPPFLAGS -I$PWD/macosx/Headers"
CPPFLAGS="$CPPFLAGS -I$PWD/macosx/Frameworks/SDL.framework/Headers"
CPPFLAGS="$CPPFLAGS -I$PWD/macosx/Frameworks/SDL_mixer.framework/Headers"
export LDFLAGS CPPFLAGS
export PATH=/usr/X11R6/bin:$PATH
ln -s $PWD/macosx/Frameworks ../Frameworks
cd macosx/Frameworks
ln -s freetype.dylib libfreetype.dylib
cd ../..
  • 2) Now you are ready to "configure" Stellarium. If you are building from CVS, type the command:
./autogen.sh
  • 2a) In both cases, you must next type the command:
./configure
  • 3) There are missing libgnuintl.h and libintl.h header files. To make these files:
cd intl
make libintl.h 
cd ..
  • 3a) If you are building from a CVS checkout, you will now need to do these steps:
cd po
make
cd ..
  • 4) At this point, you can delete the ../Frameworks file you created in the first step.
rm -f ../Frameworks

[edit] Without Fink

If you don't want to use Fink and install SDL libraries, then do as follows.

  • 1) Modify the configure script in stellarium-0.8.1 directory so that the following lines:
case "$host" in
*-*-mingw32)
;;
*-*-cygwin)
;;
*)
SDL_VERSION=1.2.0

become:

case "$host" in
*-*-mingw32)
;;
*-*-cygwin)
;;
*-*-darwin*)  <---- ADD THIS LINE
;;            <---- ADD THIS LINE
*)
SDL_VERSION=1.2.0

This skips SDL checks in configure, since SDL libraries and headers are already configured in the Xcode project.

  • 2) Follow steps 1 to 4 of building With Fink.

[edit] Fixing Bugs

  • 1) src/translator.cpp contains a Mac OS X specific macro, in the reload method, where a right brace is missing. This causes the compile to fail. Load the file in an editor or xcode and add one line:
#ifndef MACOSX	
	if (langName=="system" || langName=="system_default")
	{
		snprintf(envstr, 25, "LANGUAGE=%s", Translator::systemLangName.c_str());
//		cout << "TEST=" << envstr << " " << Translator::systemLangName << endl;
	}
	else
	{
		snprintf(envstr, 25, "LANGUAGE=%s", langName.c_str());
	}
#else
	if (langName=="system" || langName=="system_default")
	{
		snprintf(envstr, 25, "LANG=%s", Translator::systemLangName.c_str());
	}
	else
	{
		snprintf(envstr, 25, "LANG=%s", langName.c_str());	
	} <------- MISSING, MUST BE ADDED
#endif

[edit] Target settings

If you want to build an universal binary you have to modify the build settings of the Stellarium target, since they are for a PPC architecture. Open the Stellarium target properties, choose the build tab and add the i386 architecture to the Architectures setting (double click on the row and check the i386 checkbox).

This must be done for all configurations for which you want to build a universal binary.

[edit] Run and enjoy

After following the previous steps you should be able to build the project and run Stellarium natively on a Intel Mac. On my machine (Core 2 Duo 2.16 Mhz and NVIDIA 7600 GT) the fps averages 35-45 versus 8-9 frames of the PowerPC interpreted version.

[edit] Caveat

If you have have an ATI graphic card it is perfectly possible that Stellarium doesn't work anyway. I read somewhere (don't remember exactly) that there is an OpenGL bug in the ATI driver, and it could be the reason why Stellarium doesn't work on MacBook Pro or other Intel Macs with ATI cards.

In that case you must be patient and wait for MacOS 10.4.8, where it will be likely fixed.

Personal tools
Namespaces
Variants
Actions
in this wiki
other languages
Toolbox