Compiling for Mac on Linux

From The Powder Toy
Revision as of 07:27, 26 May 2021 by Simon (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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:

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

./ 64
sudo ./ 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:

Inside is a script Type ./ make lua fftw and then sudo ./ 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 download above already has a completed .app for you. You just need to copy powder-x into The 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 Credit to jacksonmj for the cross-libs script, it was only modified to compile for mac instead of windows.