Difference between revisions of "Compiling for OS X"

From The Powder Toy
Jump to: navigation, search
(Enter a short summary [ctrl-option-b])
(Update compiling guide actually work and easier to use)
Line 1: Line 1:
Note: This page is only for OS X (10.7, 10.8, 10.9) It may not work on 10.6 and below
+
This guide is for compiling TPT on OS X. it should work on all OS X versions but may have some problems on Mavericks.
Note: This guide is untested, it may not work (possibility of lua errors or errors when running the final version). 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 Xcode from the App Store [http://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12 link]
+
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].
  
2. Download xQuartz [http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.2.dmg link]
+
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].
  
3. Download SDL [http://www.libsdl.org/release/SDL-1.2.15.tar.gz link]
+
2. Install and open Xcode. Go to Xcode -> Preferences and click on Downloads. Install "Command Line Tools"
  
4. This should download to your downloads folder. Keep uncompressing until it becomes a folder.
+
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.
  
5. If you are running Mavericks (10.9); it gets a bit more involved. If not, skip to the step 6.
+
4. Download the [https://www.libsdl.org/release/SDL-1.2.15.dmg SDL framework]. Open it and copy SDL.Framework to /Libraries/Frameworks/
  
5a. Find the SDL folder (It should say "SDL-1.2.15" without the quotes) and open it. Then navigate to SDL-1.2.5/src/video/quartz
+
5. Next we need to get Lua. There are 3 options:
  
5b. Right Click (or control-click) on SDL_QuartzVideo.h and go to Open With > TextEdit (you can use Xcode if you want, but you don't need to.)
+
5a. If you have MacHomeBrew installed, install lua by typing <code bash>brew install lua</code>. You now have the Lua framework installed.
  
5c. In TextEdit, go to Edit > Find > Find.. and type <code>CGDirectPaletteRef</code> into the search box. Delete the entire line of code you find it in (delete <code>CGDirectPaletteRef palette;            /* palette of an 8-bit display */</code>)
+
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.
  
5d. Close the window.
+
5c. TPT can be compiled without lua at all, just add in the --nolua flag to scons.
  
6. In terminal, type <code bash>cd </code> (<-- Make sure there is a space after) and then drag the SDL folder in.
+
6. Now we need to get fftw, which is used to speed up Newtonian Gravity calculations. There are 2 options:
  
7. type in (or copy / paste) <code bash>./configure && make</code>
+
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.
If that comes up with an error, go to this [https://developer.apple.com/downloads/index.action# page] and download 'Command Line Tools for OS X'.  
 
  
There are several versions. Make sure to download the correct one.. If you don't know which you are using, go to the apple in the top left hand corner and press about my mac.
+
6b TPT can be compiled without fftw at all, just add the --nofft flag to scons.
  
8. After that, install SDL by typing in <code bash>sudo make install</code>
+
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>
It will ask you for your password. Type it in and press enter.
 
  
9. 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 </code> with a space after it and drag in the folder that you downloaded. 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.
+
8. Next type this into Terminal: <code bash>scons --macosx --release --sse2</code>. It will start compiling. Add the --nolua or --nofft options if you chose not to compile those libraryes.
 
 
10. If you have MacHomeBrew installed, install lua by typing <code bash>brew install lua</code>. You now have lua installed.
 
 
 
11. Go into the folder with the source code that you downloaded. Open up terminal again and type <code bash>cd </code> with a space after it. Drag in the folder with the source code.
 
 
 
12. Next type this into Terminal: <code bash>scons --macosx --release --sse2 --nofft</code>. It will start compiling.
 
  
 
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 spare code and have made a OS X application.  
  
This was written by Candunc and rewritten by jmeyer2k, 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; 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:31, 24 August 2014

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.

1. Download 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 here.

2. Install and open Xcode. Go to Xcode -> Preferences and click on Downloads. Install "Command Line Tools"

3. Now, 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.

4. Download the SDL framework. Open it and copy SDL.Framework to /Libraries/Frameworks/

5. Next we need to get Lua. There are 3 options:

5a. If you have MacHomeBrew installed, install lua by typing brew install lua. You now have the Lua framework installed.

5b. 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.

5c. TPT can be compiled without lua at all, just add in the --nolua flag to scons.

6. Now we need to get fftw, which is used to speed up Newtonian Gravity calculations. There are 2 options:

6a. 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.

6b TPT can be compiled without fftw at all, just add the --nofft flag to scons.

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 (cd ~/Documents/) and type git clone https://github.com/simtr/The-Powder-Toy.git. After this cd into the source directory with cd The-Powder-Toy/

8. Next type this into Terminal: scons --macosx --release --sse2. It will start compiling. Add the --nolua or --nofft options if you chose not to compile those libraryes.

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.

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.

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