Compiling for Mac on Linux

From The Powder Toy
Revision as of 23:26, 15 May 2015 by jacob1 (talk | contribs) (New guide for cross compiling to OS X)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Cross compiling for mac usually an almost impossible goal. The few cross compilers that exist don't work very well, and also require an actual SDK. This guide has you install a very easy to use cross compiler, which has been tested on Debian and Ubuntu based distros.

Start off by installing the libssl0.9.8 package. This is the only package required for the cross compiler to work.

Next you need to get the actual cross compiler. It is provided in 5 .deb files which you need to install in order. The links to them are here: https://launchpad.net/~flosoft/+archive/ubuntu/cross-apple/+packages . If you are on ubuntu you can try adding the ppa properly, except it probably will not work.

Install the packages in this order:

  • ccache-lipo
  • apple-x86-odcctools
  • apple-x86-gcc
  • apple-uni-sdk-10.5
  • apple-uni-framework-sdl

The rest of the packages you don't need. We install the 10.5 SDK because the 10.6 SDK doesn't seem to work.


At this point you have a full cross compiler working and can actually compile using the --nolua and --nofft options. But compiling these libraries is very easy to do. Download this file: https://dl.dropboxusercontent.com/u/43784416/PowderToy/maccrosscompile.zip

Inside is a script cross-libs.sh. Type make lua fftw and then sudo make install lua fftw. The script is already set up to download the libraries, cross compile them, and install them in the correct places.

Now it is time to compile. Go into the place where you keep your source code and type scons --mac. You can use the same folder where you compile the linux and windows versions, by adding --builddir=build/mac to make it compile in a separate directory. Ignore the compiler warnings that appear in SDLMain.m

Your compiled version will run on any 64 bit mac using OS X 10.5 or greater. It even supports fullscreen properly if you edit src/gui/options/OptionsView.cpp to enable it.

It is recommended to package the compiled binary into a .app file. The dropbox download above already has a completed .app for you. You just need to copy powder-x into Powder.app/Contents/MacOS. The Powder.app folder will be interpreted as a file by OS X. You will need to zip it up or use some other method to distribute it since you can't upload a folder.


If you have any problems following this guide, pm @jacob1 or find jacob1 in #powder on irc.freenode.net. Credit to jacksonmj for the cross-libs script, it was only modified to compile for mac instead of windows.