http://powdertoy.co.uk/Wiki/api.php?action=feedcontributions&user=RCAProduction&feedformat=atomThe Powder Toy - User contributions [en]2024-03-28T11:19:57ZUser contributionsMediaWiki 1.30.0http://powdertoy.co.uk/Wiki/index.php?title=Compiling_tpt%2B%2B_with_Visual_studio&diff=7007Compiling tpt++ with Visual studio2018-06-26T22:00:46Z<p>RCAProduction: /* Setup */ Added info to also check to add 8.1 SDK. Without it, compile errors and moans, forcing a reinstall of VS Studio if you want to compile code...</p>
<hr />
<div>This is a guide to get you started on coding for The Powder Toy. If you have any questions, just ask in the Development assistance section on [http://powdertoy.co.uk/Discussions/Categories/Topics.html?Category=5 The Powder Toy forums]. If you want to use the old tpt compiling tutorial, not the tpt++ one, find it [[Compiling_tpt_with_Visual_Studio_(old)|here]]<br />
<br />
This takes a while to setup, so be patient and follow the instructions CAREFULLY. If you get any errors, 90% of the time that means you missed a step or did something incorrectly.<br />
<br />
Do not begin coding elements until you are able to compile a clean source.<br />
<br />
Good luck!<br />
<br />
=== Get the Source ===<br />
<br />
* Go to http://github.com/ThePowderToy/The-Powder-Toy/<br />
* There should be a button that says "zip" with a cloud on it. This is a direct link to a .zip of the source. Download it and extract it to a location you will compile it from.<br />
<br />
=== Setup ===<br />
<br />
* Download [https://www.visualstudio.com/downloads/ Visual C++ 2017 Community] because of it's great debugging and auto-code tools. It is completely free, if it asks for a license see the next list item. You will need a Microsoft account to download this.<br />
* On the Workloads tab, select "Desktop development with C++"<br />
* Go into the Individual components tab, scroll down to the "Compilers, build tools, and runtimes" section, and select "Windows XP support for C++"<br />
* In the same area, select "Windows 8.1 SDK and UCRT SDK" (Without this, you can't compile the code)<br />
* Open Visual Studio. You should register it (you don't have to pay anything; it's free) with your Microsoft account if you plan on using it for more than 30 days.<br />
* Download this: [https://starcatcher.us/TPT/Required%20Libraries.zip Required Libraries.zip], and extract it right into your source code folder.<br />
<br />
* You now need python installed to run generator.py. Get python [https://www.python.org/ftp/python/3.6.5/python-3.6.5.exe here]. After you have it installed, just '''double click the generator.py file''' and it should show a console window for a second and then close. This means it worked. You '''need''' to run generator.py again every time a new element is added.<br />
<br />
==== Premade project ====<br />
<br />
Instead of going through all the steps of setting up the code, it is much easier to use a project already set up for you. You can get that here: [https://starcatcher.us/TPT/vs%20project.zip vs project.zip]<br />
It has all the options described here, plus the tpt++ source is organized in a way that makes it easier to find useful files and gets the useless ones out of the way. This is up to date fully as of June 6th, 2018.<br />
<br />
<br />
==== Manual Setup ====<br />
<br />
It is not recommended that you manually set up the project. It is easy to make mistakes and have compiling errors.<br />
<br />
* '''Make sure''' you have done everything in the Setup step correctly.<br />
<br />
* Open Visual Studio and press Press File > New > New Project from Existing Code.<br />
<br />
* Choose the folder that contains the source code, not src/, but the folder that contains src/, build/, includes/, and a few others. Name the project whatever you want. Click Next<br />
<br />
* Choose Windows application project if it isn't selected already and leave everything unchecked. Click Next.<br />
<br />
* Under Preprocessor definitions, type "WIN, X86, X86_SSE2, USE_SDL, STABLE, GRAVFFT, LUACONSOLE, IGNORE_UPDATES, _SCL_SECURE_NO_WARNINGS" without the quotes.<br />
<br />
* Click Finish. The project will be created<br />
<br />
* Under Build > Configuration Manager, open the drop-down box under "Active Solution Configuration:" and change it to "Release". (unless you have a good reason to keep it as Debug, which runs slower than Release).<br />
<br />
* Go to Project > Properties.<br />
<br />
* On the very top, where it says Configuration: Active(Release), open the dropdown and change it to All Configurations. This will make it easier if you want to switch to debug mode.<br />
<br />
* Under Configuration Properties > General:<br />
* Change Output Directory from<br />
$(SolutionDir)$(Configuration)\<br />
to <br />
$(SolutionDir)Build\<br />
(notice that there is no backslash between "$(SolutionDir)" and "Build\").<br />
* Change Target Name to whatever name you want the compiled file to have, minus the ".exe" extension. (or just leave it be to have the file named as the project name)<br />
<br />
* Under Configuration Properties > VC++ Directories:<br />
* Open the drop down menu for Include Directories (if you don't see the arrow that opens the drop-down menu, try clicking on the line), click "<Edit...>", and add<br />
$(ProjectDir)includes<br />
$(ProjectDir)includes\SDL<br />
$(ProjectDir)includes\luajit-2.0<br />
$(ProjectDir)data<br />
$(ProjectDir)src<br />
$(ProjectDir)generated<br />
(type that exactly -- also note that there is no backslash between "$(ProjectDir)" and "includes", and that they are all on separate lines)<br />
* Open the drop down menu for Library Directories, click "<Edit...>", and add<br />
$(ProjectDir)Libraries<br />
(note that there is no backslash between "$(ProjectDir)" and "Libraries")<br />
<br />
* Go to Configuration Properties > C/C++.<br />
<br />
* Under "General", open the drop-down menu for "Warning Level" and choose "Level1 (/W1)". This will make it easier if you get any errors during compiling, as you won't have to dig through a bunch of unimportant warnings to get to the errors.<br />
<br />
* Under "General", open the drop-down menu for "Multi-processor compilation" and choose "Yes (/MP)". This will make the compiler use multiple cores instead of just one which will help speed up compile times.<br />
<br />
* Under "Code Generation", open up the drop-down menu for "Floating Point Model" and set it to Fast. (this will get you a noticeable speed improvement). Also, right above it, change "Enable Enhanced Instruction Set" to SSE2.<br />
<br />
* Go to Configuration Properties > Linker > Input.<br />
<br />
* Open the drop down menu for "Additional Dependencies," click "<Edit...>", and enter the following text<br />
<br />
shell32.lib<br />
ws2_32.lib<br />
SDL.lib<br />
SDLmain.lib<br />
libbz2.lib<br />
pthreadVC2.lib<br />
luajit2.0.lib<br />
libfftw3f-3.lib<br />
zlib.lib<br />
<br />
* Press OK until you close the project properties.<br />
<br />
* Hit the F7 key on your keyboard, or click Build > Build Solution. You can also click the green "Start Debugging" arrow.<br />
* If something goes wrong (i.e. you get an error of some sort), ask on [https://powdertoy.co.uk/Discussions/Categories/Topics.html?Category=5 The Powder Toy forums].<br />
<br />
* The resulting executable and its required DLLs can be found in the "Build" folder in your source code directory.<br />
<br />
=== Optional: Statically Compile tpt: ===<br />
<br />
If you are using the premade project, it already has the Static option built in. On the top bar, select the dropdown that says "Debug" and select "Static".<br />
<br />
When statically compiling tpt, you do not need to have the dlls to run it, or distribute them with your project. The official tpt does it this way. It takes longer to compile though, so you might only want to do this for release versions.<br />
<br />
* Under Build > Configuration Manager, go under Active Solution Configuration and hit new. Name it Static (or whatever you want to call it), and select to Copy the settings from Release.<br />
<br />
* Under Configuration Properties > VC++ Directories, open the drop down menu for Library Directories, click "<Edit...>", and change it from $(ProjectDir)Libraries to:<br />
$(ProjectDir)Staticlibs<br />
<br />
* Go to Configuration Properties > Linker > Input, open the drop down menu for "Additional Dependencies," and click "<Edit...>", and add these to the list:<br />
<br />
winmm.lib<br />
imm32.lib<br />
version.lib<br />
<br />
* Go to Configuration Properties > C/C++ > Preprocessor, open the drop down menu for Preprocessor definitions, click "<Edit...>", and add these to the list:<br />
<br />
PTW32_STATIC_LIB<br />
ZLIB_WINAPI<br />
<br />
* Under "Code Generation", change "Runtime Library" to "Multi-Threaded (/MT)"<br />
<br />
* Go to Configuration Properties > Linker > Advanced, change "Image Has Safe Exception Handlers" to "No (/SAFESEH:NO)"<br />
<br />
You will now be able to easily change between compiling in "Debug" mode, for quick, normal testing, and "Static" mode, for when you want to release an exe for people to use.<br />
<br />
<br />
=== Optional: Set Up Git ===<br />
<br />
If you use github, you can easily keep up to date with the current changes. This way, your mod won't be out of date, and you won't have to copy everything over just to update to a newer version.<br />
You can find the tutorial [[Github_Setup|with this link]].<br />
<br />
=== SCons ===<br />
<br />
You can use SCons from the command line to compile with the visual studio compiler. This option probably isn't useful in most cases but is still there. Use the command "scons.py --msvc" and it will attempt to find and use a 32 bit msvc compiler. It supports most of the options in the SConscript, including --static which should generate completely static binaries (not even needing msvcr120.dll like this guide needs)<br />
<br />
[[Category:Development]]<br />
[[Category:Compiling]]</div>RCAProductionhttp://powdertoy.co.uk/Wiki/index.php?title=Compiling_for_Windows_on_Linux&diff=6252Compiling for Windows on Linux2016-11-29T00:22:40Z<p>RCAProduction: /* Compiling Libraries */</p>
<hr />
<div>This is for Linux users to cross-compile to Windows 32-bit. <br />
<br />
'''BEFORE WE START, PLEASE MAKE SURE YOU CAN COMPILE FOR LINUX FIRST!'''<br />
<br />
= Packages =<br />
First, install the basic packages needed for cross compiling.<br />
<br />
Search for the following in your package manager:<br />
''mingw32 mingw32-binutils mingw32-runtime''<br />
<br />
'''Ubuntu Users'''<br />
Run the following in a terminal:<br><br />
<code>sudo apt-get install mingw-w64</code><br />
<br />
In older recent versions of Ubuntu, try:<br><br />
<code>sudo apt-get install mingw32 mingw32-binutils mingw32-runtime</code><br />
<br />
'''Debian Users'''<br />
In a terminal:<br><br />
<code>su -c "apt-get install mingw32 mingw32-binutils mingw32-runtime"</code><br />
<br />
'''Arch Users'''<br />
In your Terminal:<br><br />
<code>su -c 'pacman -S mingw32-{gcc,binutils,runtime}'</code><br />
<br />
After you have installed these, there should be /usr/XXXX-mingw32msvc , XXXX may be i486, i586, i686 or something else. Anywhere further in this tutorial i will refer to the folder name as $MINGW , for instance /usr/$MINGW/lib <br />
You could actually set such an environment variable for simplicity.<br />
<br />
= Libraries =<br />
Next, Powder Toy needs a couple of libraries. There are three ways to get them:<br />
* Package repositories. This is sometimes the easiest way, but not all distributions have MinGW versions of all the required libraries in their package repositories<br />
* Download and extract precompiled libraries. However, you usually cannot statically compile when using this way<br />
* Compile from source. This would normally be difficult, but there is a script available to help you. You'll need to use this method if you don't want to distribute DLL files with your executables. <br />
<br />
The libraries needed are:<br />
* SDL<br />
* bzip2<br />
* pthread<br />
* Lua (optional - if you don't want to use it, use --nolua option)<br />
* FFTW (optional - if you don't want to use it, use --nofft option)<br />
<br />
== Compiling Libraries==<br />
By compiling all the libraries yourself, the final executable will not need any DLLs to run.<br />
<br />
Since figuring out all the right commands to cross compile the libraries can be difficult, here is a script that has all the right commands already: https://dl.dropboxusercontent.com/u/43784416/PowderToy/cross-libs.sh?dl=1<br />
<br />
Running the script without arguments provides usage instructions. Start by changing the variables at the start of the script to match your MinGW installation. The default values are:<br /><br />
HOST="i686-w64-mingw32" <br />
MINGW_BIN_PREFIX="i686-w64-mingw32-" <br />
MINGW_INSTALL_DIR="/usr/i686-w64-mingw32" <br />
<b>On older versions of Debian/Ubuntu,</b> you might change this to: <br />
HOST="i586-mingw32msvc"<br />
MINGW_BIN_PREFIX="i586-mingw32msvc-"<br />
MINGW_INSTALL_DIR="/usr/i586-mingw32msvc"<br />
<br />
Please note, if you installed MingW for <b>older recent versions of Ubuntu</b> as shown in step 1, you <u>MUST</u> change these variables.<br />
<br />
Now compile and install the libraries as follows (they will automatically be downloaded. Simply open a terminal, and enter the following code):<br />
<br />
<code>cd /Downloads/</code><br />
<br />
<code>sudo ./cross-libs.sh make bzip2 fftw lua pthread regex sdl zlib</code><br />
<br />
<code>sudo ./cross-libs.sh install bzip2 fftw lua pthread regex sdl zlib</code><br />
<br />
If the script doesn't run, you need to allow the file to be run as an executable. You can do this very easily. Find cross-libs.sh in your downloads folder. Right click, and go to the Properties button. With this window open, click the Permissions tab. Down near the bottom is an option named "Execute". Make sure that the box is checked which says "Allow executing file as program". Now, go back and run the code in the terminal again.<br />
<br />
= Compile =<br />
It should be as simple as <br />
<code>scons --win</code><br />
<br />
Some SConscript changes may be needed if the name of your cross compiler isn't standard (or just not listed in the SConscript). If it does not detect your cross compiler, try using: <br />
<code>scons --win --tool=$MINGW-</code><br /><br />
Notice the dash, if for you $MINGW is i586-mingw32msvc you should pass <code>--tool=i586-mingw32msvc-</code>.<br />
<br />
If you have problems with initial libraries lookup, it is useful to check config.log for obvious failures.<br />
<br />
If when linking it gives you an error like<br />
<br />
<code>/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++.a(stubs.o):(.text+0x540): multiple definition of `_coshf'<br />
<br />
build/src/Misc.o:Misc.cpp:(.text$coshf[_coshf]+0x0): first defined here</code><br />
<br />
do this (under root):<br />
<br />
<code>cd /usr/lib/gcc/$MINGW/4.2.1-sjlj/<br />
<br />
$MINGW-ar -d libstdc++.a stubs.o</code><br />
<br />
If this tutorial has any obvious (and not very obvious) failures, feel free to edit.<br />
[[Category:Development]]<br />
[[Category:Compiling]]</div>RCAProductionhttp://powdertoy.co.uk/Wiki/index.php?title=Compiling_for_Windows_on_Linux&diff=6251Compiling for Windows on Linux2016-11-29T00:15:56Z<p>RCAProduction: /* Compiling Libraries */</p>
<hr />
<div>This is for Linux users to cross-compile to Windows 32-bit. <br />
<br />
'''BEFORE WE START, PLEASE MAKE SURE YOU CAN COMPILE FOR LINUX FIRST!'''<br />
<br />
= Packages =<br />
First, install the basic packages needed for cross compiling.<br />
<br />
Search for the following in your package manager:<br />
''mingw32 mingw32-binutils mingw32-runtime''<br />
<br />
'''Ubuntu Users'''<br />
Run the following in a terminal:<br><br />
<code>sudo apt-get install mingw-w64</code><br />
<br />
In older recent versions of Ubuntu, try:<br><br />
<code>sudo apt-get install mingw32 mingw32-binutils mingw32-runtime</code><br />
<br />
'''Debian Users'''<br />
In a terminal:<br><br />
<code>su -c "apt-get install mingw32 mingw32-binutils mingw32-runtime"</code><br />
<br />
'''Arch Users'''<br />
In your Terminal:<br><br />
<code>su -c 'pacman -S mingw32-{gcc,binutils,runtime}'</code><br />
<br />
After you have installed these, there should be /usr/XXXX-mingw32msvc , XXXX may be i486, i586, i686 or something else. Anywhere further in this tutorial i will refer to the folder name as $MINGW , for instance /usr/$MINGW/lib <br />
You could actually set such an environment variable for simplicity.<br />
<br />
= Libraries =<br />
Next, Powder Toy needs a couple of libraries. There are three ways to get them:<br />
* Package repositories. This is sometimes the easiest way, but not all distributions have MinGW versions of all the required libraries in their package repositories<br />
* Download and extract precompiled libraries. However, you usually cannot statically compile when using this way<br />
* Compile from source. This would normally be difficult, but there is a script available to help you. You'll need to use this method if you don't want to distribute DLL files with your executables. <br />
<br />
The libraries needed are:<br />
* SDL<br />
* bzip2<br />
* pthread<br />
* Lua (optional - if you don't want to use it, use --nolua option)<br />
* FFTW (optional - if you don't want to use it, use --nofft option)<br />
<br />
== Compiling Libraries==<br />
By compiling all the libraries yourself, the final executable will not need any DLLs to run.<br />
<br />
Since figuring out all the right commands to cross compile the libraries can be difficult, here is a script that has all the right commands already: https://dl.dropboxusercontent.com/u/43784416/PowderToy/cross-libs.sh?dl=1<br />
<br />
Running the script without arguments provides usage instructions. Start by changing the variables at the start of the script to match your MinGW installation. The default values are:<br /><br />
HOST="i686-w64-mingw32" <br />
MINGW_BIN_PREFIX="i686-w64-mingw32-" <br />
MINGW_INSTALL_DIR="/usr/i686-w64-mingw32" <br />
<b>On older versions of Debian/Ubuntu,</b> you might change this to: <br />
HOST="i586-mingw32msvc"<br />
MINGW_BIN_PREFIX="i586-mingw32msvc-"<br />
MINGW_INSTALL_DIR="/usr/i586-mingw32msvc"<br />
<br />
Now compile and install the libraries as follows (they will automatically be downloaded):<br />
<br />
<code>./cross-libs.sh make bzip2 fftw lua pthread regex sdl zlib</code><br />
<br />
<code>sudo ./cross-libs.sh install bzip2 fftw lua pthread regex sdl zlib</code><br />
<br />
= Compile =<br />
It should be as simple as <br />
<code>scons --win</code><br />
<br />
Some SConscript changes may be needed if the name of your cross compiler isn't standard (or just not listed in the SConscript). If it does not detect your cross compiler, try using: <br />
<code>scons --win --tool=$MINGW-</code><br /><br />
Notice the dash, if for you $MINGW is i586-mingw32msvc you should pass <code>--tool=i586-mingw32msvc-</code>.<br />
<br />
If you have problems with initial libraries lookup, it is useful to check config.log for obvious failures.<br />
<br />
If when linking it gives you an error like<br />
<br />
<code>/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++.a(stubs.o):(.text+0x540): multiple definition of `_coshf'<br />
<br />
build/src/Misc.o:Misc.cpp:(.text$coshf[_coshf]+0x0): first defined here</code><br />
<br />
do this (under root):<br />
<br />
<code>cd /usr/lib/gcc/$MINGW/4.2.1-sjlj/<br />
<br />
$MINGW-ar -d libstdc++.a stubs.o</code><br />
<br />
If this tutorial has any obvious (and not very obvious) failures, feel free to edit.<br />
[[Category:Development]]<br />
[[Category:Compiling]]</div>RCAProductionhttp://powdertoy.co.uk/Wiki/index.php?title=Compiling_for_Windows_on_Linux&diff=6249Compiling for Windows on Linux2016-11-18T23:09:42Z<p>RCAProduction: /* Compiling Libraries */</p>
<hr />
<div>This is for Linux users to cross-compile to Windows 32-bit. <br />
<br />
'''BEFORE WE START, PLEASE MAKE SURE YOU CAN COMPILE FOR LINUX FIRST!'''<br />
<br />
= Packages =<br />
First, install the basic packages needed for cross compiling.<br />
<br />
Search for the following in your package manager:<br />
''mingw32 mingw32-binutils mingw32-runtime''<br />
<br />
'''Ubuntu Users'''<br />
Run the following in a terminal:<br><br />
<code>sudo apt-get install mingw-w64</code><br />
<br />
In older recent versions of Ubuntu, try:<br><br />
<code>sudo apt-get install mingw32 mingw32-binutils mingw32-runtime</code><br />
<br />
'''Debian Users'''<br />
In a terminal:<br><br />
<code>su -c "apt-get install mingw32 mingw32-binutils mingw32-runtime"</code><br />
<br />
'''Arch Users'''<br />
In your Terminal:<br><br />
<code>su -c 'pacman -S mingw32-{gcc,binutils,runtime}'</code><br />
<br />
After you have installed these, there should be /usr/XXXX-mingw32msvc , XXXX may be i486, i586, i686 or something else. Anywhere further in this tutorial i will refer to the folder name as $MINGW , for instance /usr/$MINGW/lib <br />
You could actually set such an environment variable for simplicity.<br />
<br />
= Libraries =<br />
Next, Powder Toy needs a couple of libraries. There are three ways to get them:<br />
* Package repositories. This is sometimes the easiest way, but not all distributions have MinGW versions of all the required libraries in their package repositories<br />
* Download and extract precompiled libraries. However, you usually cannot statically compile when using this way<br />
* Compile from source. This would normally be difficult, but there is a script available to help you. You'll need to use this method if you don't want to distribute DLL files with your executables. <br />
<br />
The libraries needed are:<br />
* SDL<br />
* bzip2<br />
* pthread<br />
* Lua (optional - if you don't want to use it, use --nolua option)<br />
* FFTW (optional - if you don't want to use it, use --nofft option)<br />
<br />
== Compiling Libraries==<br />
By compiling all the libraries yourself, the final executable will not need any DLLs to run.<br />
<br />
Since figuring out all the right commands to cross compile the libraries can be difficult, here is a script that has all the right commands already: https://dl.dropboxusercontent.com/u/43784416/PowderToy/cross-libs.sh?dl=1<br />
<br />
Running the script without arguments provides usage instructions. Start by changing the variables at the start of the script to match your MinGW installation. The default values are:<br /><br />
HOST="i686-w64-mingw32" <br />
MINGW_BIN_PREFIX="i686-w64-mingw32-" <br />
MINGW_INSTALL_DIR="/usr/i686-w64-mingw32" <br />
On older versions of Debian/Ubuntu, you might change this to: <br />
HOST="i586-mingw32msvc"<br />
MINGW_BIN_PREFIX="i586-mingw32msvc-"<br />
MINGW_INSTALL_DIR="/usr/i586-mingw32msvc"<br />
<br />
Now compile and install the libraries as follows (they will automatically be downloaded):<br />
<br />
<code>./cross-libs.sh make bzip2 fftw lua pthread regex sdl zlib</code><br />
<br />
<code>sudo ./cross-libs.sh install bzip2 fftw lua pthread regex sdl zlib</code><br />
<br />
= Compile =<br />
It should be as simple as <br />
<code>scons --win</code><br />
<br />
Some SConscript changes may be needed if the name of your cross compiler isn't standard (or just not listed in the SConscript). If it does not detect your cross compiler, try using: <br />
<code>scons --win --tool=$MINGW-</code><br /><br />
Notice the dash, if for you $MINGW is i586-mingw32msvc you should pass <code>--tool=i586-mingw32msvc-</code>.<br />
<br />
If you have problems with initial libraries lookup, it is useful to check config.log for obvious failures.<br />
<br />
If when linking it gives you an error like<br />
<br />
<code>/usr/lib/gcc/i586-mingw32msvc/4.2.1-sjlj/libstdc++.a(stubs.o):(.text+0x540): multiple definition of `_coshf'<br />
<br />
build/src/Misc.o:Misc.cpp:(.text$coshf[_coshf]+0x0): first defined here</code><br />
<br />
do this (under root):<br />
<br />
<code>cd /usr/lib/gcc/$MINGW/4.2.1-sjlj/<br />
<br />
$MINGW-ar -d libstdc++.a stubs.o</code><br />
<br />
If this tutorial has any obvious (and not very obvious) failures, feel free to edit.<br />
[[Category:Development]]<br />
[[Category:Compiling]]</div>RCAProductionhttp://powdertoy.co.uk/Wiki/index.php?title=Compiling_for_Mac_on_Linux&diff=5699Compiling for Mac on Linux2015-07-31T04:45:58Z<p>RCAProduction: Don't even know what libssl0.9.8 is. I'm on a fresh distro, and didn't need to install it, made a note of such.</p>
<hr />
<div>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.<br />
<br />
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.<br />
<br />
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.<br />
<br />
Install the packages in this order:<br />
<ul><li>ccache-lipo</li><br />
<li>apple-x86-odcctools</li><br />
<li>apple-uni-sdk-10.5</li><br />
<li>apple-x86-gcc</li><br />
<li>apple-uni-framework-sdl</li></ul><br />
<br />
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.<br />
<br />
<br />
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<br />
<br />
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.<br />
<br />
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<br />
<br />
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.<br />
<br />
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.<br />
<br />
<br />
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.<br />
<br />
[[Category:Development]]<br />
[[Category:Compiling]]</div>RCAProductionhttp://powdertoy.co.uk/Wiki/index.php?title=Compiling_for_Mac_on_Linux&diff=5697Compiling for Mac on Linux2015-07-31T04:36:34Z<p>RCAProduction: Changed file download order.</p>
<hr />
<div>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.<br />
<br />
Start off by installing the libssl0.9.8 package. This is the only package required for the cross compiler to work.<br />
<br />
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.<br />
<br />
Install the packages in this order:<br />
<ul><li>ccache-lipo</li><br />
<li>apple-x86-odcctools</li><br />
<li>apple-uni-sdk-10.5</li><br />
<li>apple-x86-gcc</li><br />
<li>apple-uni-framework-sdl</li></ul><br />
<br />
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.<br />
<br />
<br />
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<br />
<br />
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.<br />
<br />
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<br />
<br />
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.<br />
<br />
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.<br />
<br />
<br />
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.<br />
<br />
[[Category:Development]]<br />
[[Category:Compiling]]</div>RCAProduction