Difference between revisions of "Compiling for OS X"

From The Powder Toy
Jump to: navigation, search
m (remove unnecessary / broken flags)
(revamped and sectioned the entire tutorial. also all libs except sdl are on homebrew)
Line 3: Line 3:
 
If there are problems, try posting your errors on the development help section of the forums, or coming onto [http://webchat.freenode.net/?channels=#powder irc].
 
If there are problems, try posting your errors on the development help section of the forums, or coming onto [http://webchat.freenode.net/?channels=#powder irc].
  
1. Download [http://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12 Xcode] from the App Store. If you are on OS X 10.7 you will have to register a developer account and download 4.6.3 [https://developer.apple.com/downloads/index.action here].
+
== Installing the command-line tools ==
  
2. Install and open Xcode. Go to Xcode -> Preferences and click on Downloads. Install "Command Line Tools"
+
If you're on the latest version of OSX and feel like downloading 3 GB of baggage, grab the full version of Xcode from the app store.
  
3. Now, download [http://prdownloads.sourceforge.net/scons/scons-2.3.0.zip scons] and unzip it. Go into the terminal, and type in <code bash>cd ~/Downloads/scons-2.3.0/</code> (you can use tab to complete a folder name so you don't have to type it all out). Next type <code bash>sudo python setup.py install</code>. The terminal will ask you for your password. Note that you can not see your password while you are typing it in. You now have scons installed. Keep the terminal open for later.
+
Otherwise, there are some smaller downloads for just the command line tools in the [https://developer.apple.com/downloads/index.action?name=Xcode Apple developer website]. You'll need an [https://developer.apple.com/register/ Apple ID with developer access] to get to it, though!
  
4. Download the [https://www.libsdl.org/release/SDL-1.2.15.dmg SDL framework]. Open it and copy SDL.Framework to /Libraries/Frameworks/
+
If you got Xcode, go to Xcode -> Preferences and click on Downloads. Install "Command Line Tools". This will give you the various tools we'll need.  
  
5. Next we need to get Lua. There are 3 options:
+
== Option #1: Homebrew ==
  
5a. If you have MacHomeBrew installed, install lua by typing <code bash>brew install lua</code>. You now have the Lua framework installed.
+
Install [http://brew.sh Homebrew] - this will give you easy access to each of the libraries below. You can then install almost all the necessary tools and libraries with it:
 +
<code bash>brew install fftw lua scons</code>
 +
You still need to install SDL the old way!
  
5b. Download the [http://www.lua.org/ftp/lua-5.1.5.tar.gz lua source]. Double click to extract it, then go back to the terminal and type <code bash>cd ../lua-5.1.5/</code>. Once in the lua folder, type <code bash>make macosx</code> and then <code bash>sudo make install</code>. The lua library is now installed.
+
== Option #2: Manual library installation ==
  
5c. TPT can be compiled without lua at all, just add in the --nolua flag to scons.
+
=== Compiling scons ===
  
6. Now we need to get fftw, which is used to speed up Newtonian Gravity calculations. There are 2 options:
+
Download [http://prdownloads.sourceforge.net/scons/scons-2.3.0.zip scons] and unzip it. Go into the terminal, and type in <code bash>cd ~/Downloads/scons-2.3.0/</code>
 +
(you can use tab to complete a folder name so you don't have to type it all out). Next type <code bash>sudo python setup.py install</code>. The terminal will ask you for your password. Note that you can not see your password while you are typing it in. You now have scons installed. Keep the terminal open for later.
  
6a. Download the [http://www.fftw.org/fftw-3.3.4.tar.gz fftw3 source]. Double click to extract it, then go back to the terminal and type <code bash>cd ../fftw-3.3.4/</code>. Once in the fftw folder, type <code bash>./configure && make </code>. Some different options may be needed to make it compile (I used a lot) but maybe this works.
+
=== Getting Lua ===
  
6b TPT can be compiled without fftw at all, just add the --nofft flag to scons.
+
Download the [http://www.lua.org/ftp/lua-5.1.5.tar.gz lua source]. Double click to extract it, then go back to the terminal and type <code bash>cd ../lua-5.1.5/</code>. Once in the lua folder, type <code bash>make macosx</code> and then <code bash>sudo make install</code>. The lua library is now installed.
  
7. Now we need to get the actual source. Installing "Command Line Tools" should have installed git, so go somewhere you want to put the code (<code bash>cd ~/Documents/</code>) and type <code bash>git clone https://github.com/simtr/The-Powder-Toy.git</code>. After this cd into the source directory with <code bash>cd The-Powder-Toy/</code>
+
=== Getting FFTW ===
  
8. Next type this into Terminal: <code bash>scons</code>. It will start compiling. Add the --nolua or --nofft options if you chose not to compile those libraries.
+
Download the [http://www.fftw.org/fftw-3.3.4.tar.gz fftw3 source]. Double click to extract it, then go back to the terminal and type <code bash>cd ../fftw-3.3.4/</code>. Once in the fftw folder, type <code bash>./configure && make </code>. Some different options may be needed to make it compile (I used a lot) but maybe this works.
 +
 
 +
== Getting SDL ==
 +
 
 +
'''Note: you still need to do this if you used Homebrew to install the other libraries!'''
 +
 
 +
Download the [https://www.libsdl.org/release/SDL-1.2.15.dmg SDL framework]. Open the freshly downloaded DMG file and drag SDL.Framework to the folder <code>/Library/Frameworks/</code>
 +
 
 +
== Getting TPT source code ==
 +
 
 +
Make a new folder in your Documents called "TPT" - this will become your project directory for all the TPT source code. We'll now download the entire commit history to that folder - this will let you add your own commits, creating your unique code project.
 +
 
 +
First, use <code bash>cd ~/Documents/TPT</code> to move to the project directory, then
 +
<code bash>git clone https://github.com/simtr/The-Powder-Toy.git .</code> to clone all the history. The dot at the end means that we'll rather not make a new subdirectory inside the TPT project directory.
 +
 
 +
At the end of this we have a fully functional environment to build, as well as a local copy of the entire project. Great job! :D
 +
 
 +
== Building ==
 +
 
 +
This is the part you've been waiting for - type <code bash>scons</code> into the terminal and press enter. The script will check if your environment is alright (it is) and then it'll start compiling each of the source code files.  
 +
 
 +
== Aftermath ==
  
 
If it compiled without errors, you will find a file called powder-x in the build folder. Double click it and run it.
 
If it compiled without errors, you will find a file called powder-x in the build folder. Double click it and run it.
Congrats, you have compiled spare code and have made a OS X application.  
+
Congrats, you have compiled the source code and have made a OS X application.  
  
This was written by Candunc, rewritten by jmeyer2k, and fixed again by jacob1; although parts were copied from the Mac OS X compile page. Thanks to the editors on the Mac OS X compile page, and thanks to people at Mac Rumors and Ximon to help me find out various errors.
+
This was written by Candunc, rewritten by jmeyer2k, and fixed again by jacob1, and cleaned up by boxmein, although parts were copied from the Mac OS X compile page. Thanks to the editors on the Mac OS X compile page, and thanks to people at Mac Rumors and Ximon to help me find out various errors.
  
 
I hope this helps future users become Mac Compilers and push TPT to Mac users!
 
I hope this helps future users become Mac Compilers and push TPT to Mac users!
  
 
[[Category:Compiling]]
 
[[Category:Compiling]]

Revision as of 01:06, 17 April 2015

This guide is for compiling TPT on OS X. it should work on all OS X versions but may have some problems on Mavericks.

If there are problems, try posting your errors on the development help section of the forums, or coming onto irc.

Installing the command-line tools

If you're on the latest version of OSX and feel like downloading 3 GB of baggage, grab the full version of Xcode from the app store.

Otherwise, there are some smaller downloads for just the command line tools in the Apple developer website. You'll need an Apple ID with developer access to get to it, though!

If you got Xcode, go to Xcode -> Preferences and click on Downloads. Install "Command Line Tools". This will give you the various tools we'll need.

Option #1: Homebrew

Install Homebrew - this will give you easy access to each of the libraries below. You can then install almost all the necessary tools and libraries with it: brew install fftw lua scons You still need to install SDL the old way!

Option #2: Manual library installation

Compiling scons

Download scons and unzip it. Go into the terminal, and type in cd ~/Downloads/scons-2.3.0/ (you can use tab to complete a folder name so you don't have to type it all out). Next type sudo python setup.py install. The terminal will ask you for your password. Note that you can not see your password while you are typing it in. You now have scons installed. Keep the terminal open for later.

Getting Lua

Download the lua source. Double click to extract it, then go back to the terminal and type cd ../lua-5.1.5/. Once in the lua folder, type make macosx and then sudo make install. The lua library is now installed.

Getting FFTW

Download the fftw3 source. Double click to extract it, then go back to the terminal and type cd ../fftw-3.3.4/. Once in the fftw folder, type ./configure && make . Some different options may be needed to make it compile (I used a lot) but maybe this works.

Getting SDL

Note: you still need to do this if you used Homebrew to install the other libraries!

Download the SDL framework. Open the freshly downloaded DMG file and drag SDL.Framework to the folder /Library/Frameworks/

Getting TPT source code

Make a new folder in your Documents called "TPT" - this will become your project directory for all the TPT source code. We'll now download the entire commit history to that folder - this will let you add your own commits, creating your unique code project.

First, use cd ~/Documents/TPT to move to the project directory, then git clone https://github.com/simtr/The-Powder-Toy.git . to clone all the history. The dot at the end means that we'll rather not make a new subdirectory inside the TPT project directory.

At the end of this we have a fully functional environment to build, as well as a local copy of the entire project. Great job! :D

Building

This is the part you've been waiting for - type scons into the terminal and press enter. The script will check if your environment is alright (it is) and then it'll start compiling each of the source code files.

Aftermath

If it compiled without errors, you will find a file called powder-x in the build folder. Double click it and run it. Congrats, you have compiled the source code and have made a OS X application.

This was written by Candunc, rewritten by jmeyer2k, and fixed again by jacob1, and cleaned up by boxmein, although parts were copied from the Mac OS X compile page. Thanks to the editors on the Mac OS X compile page, and thanks to people at Mac Rumors and Ximon to help me find out various errors.

I hope this helps future users become Mac Compilers and push TPT to Mac users!