Compiling for Mac on Linux

From The Powder Toy
Jump to: navigation, search

ATTENTION: This guide is outdated as of 2021. Please use this guide for building any recent version of the game: Building TPT with Meson

The official version is compiled with osxcross: https://github.com/tpoechtrager/osxcross

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. NOTE: You may not need to install this, if it came with your particular distro.

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-uni-sdk-10.5
  • apple-x86-gcc
  • 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.

All of the previous steps can be done easily with two scripts that are included. Just type these commands:

./getpackages.sh 64
sudo ./installpackages.sh 64

Replace 64 with 32 if you are using a 32 bit OS.


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: maccrosscompile.zip

Inside is a script cross-libs.sh. Type ./cross-libs.sh make lua fftw and then sudo ./cross-libs.sh 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 maccrosscompile.zip 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.libera.chat. Credit to jacksonmj for the cross-libs script, it was only modified to compile for mac instead of windows.