Difference between revisions of "Compiling for Mac on Linux"

From The Powder Toy
Jump to: navigation, search
m (fix mistake in command to run)
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 +
'''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.
 
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.
+
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.
 
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.
Line 8: Line 12:
 
<ul><li>ccache-lipo</li>
 
<ul><li>ccache-lipo</li>
 
<li>apple-x86-odcctools</li>
 
<li>apple-x86-odcctools</li>
 +
<li>apple-uni-sdk-10.5</li>
 
<li>apple-x86-gcc</li>
 
<li>apple-x86-gcc</li>
<li>apple-uni-sdk-10.5</li>
 
 
<li>apple-uni-framework-sdl</li></ul>
 
<li>apple-uni-framework-sdl</li></ul>
  
 
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.
 
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: https://dl.dropboxusercontent.com/u/43784416/PowderToy/maccrosscompile.zip
+
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://drive.google.com/uc?id=0B1XWtCTn2YPARnhXZGVWUmE1a1k&export=download maccrosscompile.zip]
  
Inside is a script cross-libs.sh. Type <code>./cross-libs.sh lua fftw</code> and then <code>sudo ./cross-libs.sh install lua fftw</code>. The script is already set up to download the libraries, cross compile them, and install them in the correct places.
+
Inside is a script cross-libs.sh. Type <code>./cross-libs.sh make lua fftw</code> and then <code>sudo ./cross-libs.sh install lua fftw</code>. 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 <code>scons --mac</code>. You can use the same folder where you compile the linux and windows versions, by adding <code>--builddir=build/mac</code> to make it compile in a separate directory. Ignore the compiler warnings that appear in SDLMain.m
 
Now it is time to compile. Go into the place where you keep your source code and type <code>scons --mac</code>. You can use the same folder where you compile the linux and windows versions, by adding <code>--builddir=build/mac</code> to make it compile in a separate directory. Ignore the compiler warnings that appear in SDLMain.m
Line 23: Line 32:
 
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.
 
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.
+
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.freenode.net. Credit to jacksonmj for the cross-libs script, it was only modified to compile for mac instead of windows.
+
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.
  
 
[[Category:Development]]
 
[[Category:Development]]
 
[[Category:Compiling]]
 
[[Category:Compiling]]

Latest revision as of 07:27, 26 May 2021

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.