Difference between revisions of "Compiling tpt with Visual Studio (old)"

From The Powder Toy
Jump to: navigation, search
(talk)
 
m (moved Compiling for Windows to Compiling tpt with Visual Studio (old): since it won't work anymore, also more specific title)
 
(31 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<h3> Setting up GitHub and Visual Studio for Coding </h4>
+
'''Note: this guide is outdated and will only work for the old c source'''
 +
 
 +
 
 +
 
 +
 
 
'''Original author:''' Triclops200
 
'''Original author:''' Triclops200
  
'''Main contributors:''' raj.k, HolyExLxF, FacialTurd(Simon)
+
'''Main contributors:''' raj.k, HolyExLxF, FacialTurd(Simon), Jacob1
  
 
'''"Small" authors:''' wikku9 (added quotations marks to Additional Dependecies list and other)
 
'''"Small" authors:''' wikku9 (added quotations marks to Additional Dependecies list and other)
 
,Pyromaniac555 (fixed lists, checked spelling and grammar, etc. (still checking)), Me4502 (added pthread link)
 
,Pyromaniac555 (fixed lists, checked spelling and grammar, etc. (still checking)), Me4502 (added pthread link)
 
  
  
 
<ins>This guide is for Windows</ins>
 
<ins>This guide is for Windows</ins>
  
 
+
The Linux guide to setup is [[Building in linux| here]].  
 
 
The GNU/Linux guide to setup is [[Building in Linux| here]].  
 
 
 
 
 
  
 
Contributors are welcome to port this tutorial to Mac OS X (or improve the existing tutorials).
 
Contributors are welcome to port this tutorial to Mac OS X (or improve the existing tutorials).
Line 21: Line 20:
  
  
---
+
----
 
 
 
 
  
This is a guide to get you started on coding for The Powder Toy. If you have any questions, just ask in the Discussion section on [https://powdertoy.co.uk/Forum.html| The Powder Toy forums].
 
  
  
 +
This is a guide to get you started on coding for The Powder Toy. If you have any questions, just ask in the Discussion section on [https://powdertoy.co.uk/Forum.html The Powder Toy forums].
  
 
It would help if you have programmed before, but it is fine if you never have.
 
It would help if you have programmed before, but it is fine if you never have.
 
 
  
 
This takes a while to setup, so be patient and follow the instructions carefully.
 
This takes a while to setup, so be patient and follow the instructions carefully.
  
 
+
Its not recommended to begin coding elements until you are able to compile a clean source.
 
 
Its not recommended to begin coding elements until you are able to compile a clean source,
 
 
 
 
 
  
 
Good luck!
 
Good luck!
  
  
 
+
====  GitHub Set-up ====
<h4> GitHub Set-up </h5>
+
'''GitHub set-up can be skipped, just go to 'Visual Studio (Windows)''''   
GitHub set-up can be skipped, just go to 'Visual Studio (Windows)'   
 
  
 
Doing these steps in order is highly recommended.
 
Doing these steps in order is highly recommended.
Line 53: Line 43:
  
 
* Create an account at this site: [[https://github.com/]].
 
* Create an account at this site: [[https://github.com/]].
* Download and install [http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.1-preview20100612.exe&can=2&q=| MySysGit].
+
* Download and install [http://code.google.com/p/msysgit/downloads/detail?name=Git-1.7.7-preview20111014.exe&can=2&q=| MySysGit].
* Download and install [http://www.syntevo.com/smartgit/index.html| SmartGit].
+
* Download and install [http://www.syntevo.com/smartgit/index.html SmartGit].
 
* Set up SmartGit:
 
* Set up SmartGit:
 
* Choose Non Commercial so you can get unlimited use.
 
* Choose Non Commercial so you can get unlimited use.
Line 90: Line 80:
  
  
If something goes wrong, go to [[http:''support.github.com/discussions/repos| GitHub forums]] for git help or ask on [[http:''powdertoy.co.uk| The Powder Toy forums]] for powder toy help.
+
If something goes wrong, go to [http://support.github.com/discussions/repos GitHub forums] for git help or ask on [https://powdertoy.co.uk/Forum.html The Powder Toy forums] for powder toy help.
  
  
Line 98: Line 88:
  
  
<h4> Visual Studio (Windows) </h5>
+
====  Visual Studio (Windows) ====
If you can't be arsed to do any of this yourself (It is a bit outdated I agree) then I have uploaded a complete visual studio 2010 project with source (as of latest 61.3). http://www.box.net/shared/xzarykzoraiorpi41iy1
+
If you can't be bothered to do any of this yourself, then I have uploaded a complete visual studio 2010 project with source (for v82.0 of Powder Toy). https://www.box.com/s/xzarykzoraiorpi41iy1
It has all the libraries and headers you need to compile the latest version, it statically links everything so no .dll's needed!  It also has a git repository in it, which you *should* be able to pull from. It doesn't run quite as fast as the official, but you can easily add things for testing :)
+
It has all the libraries and headers you need to compile this version, it statically links everything so no .dll's needed!  Just remember to switch it to release mode for better performance/size.
 +
 
 +
* Download [http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express Visual C++ 2010 Express] because of it's great debugging and auto-code tools. It is completely free.
 +
* Open Visual Studio. You should register it (you don't have to pay anything; it's free) if you plan on using it for more than 30 days.
 +
* If you wish, (this should already be on by default), turn on line numbers by going to Tools > Options > Text Editor > C/C++, and turn on "Line numbers" in the Display subsection.
 +
 
 +
* Download this: [http://minus.com/lbmWUn6MSa6Sw2 Required Libraries] (extract it right into your source code folder) (or, if you want a statically linked version that doesn't need a bunch of DLL files to run, download [http://minus.com/lbwUm5QXJbi0eY this], but be warned that these libraries may or may not work, and linking may take a very long time to complete)
 +
 
 +
* Press File > New > New Project from Existing Code.
 +
 
 +
* Choose the folder from your source code folder.
 +
 
 +
* Choose Windows application project and leave everything unchecked. Press "Finish". (You don't need to change any of the other options)
 +
 
 +
* 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)
 +
 
 +
* Go to Project > Properties.
  
Download Pthread here ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.exe
+
* Under Configuration Properties > General:
 +
* Change Output Directory from
 +
$(SolutionDir)$(Configuration)\
 +
to
 +
$(SolutionDir)Build\
 +
(notice that there is no backslash between "$(SolutionDir)" and "Build\").
 +
* 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)
  
'''<ins><source> should be replaced by the appropriate folder where the source code is located!</ins>'''
+
* Under Configuration Properties > VC++ Directories:
 +
* 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
 +
$(ProjectDir)Includes
 +
(type that exactly -- also note that there is no backslash between "$(ProjectDir)" and "Includes")
 +
* It's important to make sure, after you click OK to close the "Include Directories" dialog box, that this comes ''before'' everything else under "Include Directories" -- otherwise you'll get some nasty errors when you try to compile.
 +
* Open the drop down menu for Library Directories, click "<Edit...>", and add
 +
$(ProjectDir)Libraries
 +
(note that there is no backslash between "$(ProjectDir)" and "Libraries")
  
 +
* Go to Configuration Properties > C/C++.
  
 +
* Under "General", open the drop-down menu for "Warning Level" and choose the option to turn off all warnings. (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.)
 +
* Under "Preprocessor", open the drop-down for "Preprocessor Definitions", click "<Edit...>", and add (if you're using the static libraries, you'll have to use the list from the "Preprocessor definitions.txt" file located in the zip file with the libraries you downloaded instead of this list below):
 +
LUACONSOLE
 +
GRAVFFT
 +
X86
 +
X86_SSE2
  
* [http://www.microsoft.com/express/Downloads/#2010-Visual-CPP| Visual Studio Express 2010 C++] because of it's great debugging and auto-code tools. It is completely free.
+
* If for some reason the libfftw3f-3.lib included in the Libraries folder doesn't work (it should), try using [http://www.fftw.org/install/windows.html this one] (and follow the instructions on the site).
* Open Visual Studio. If you didn't get a product key, go to [http://www.microsoft.com/express/support/regins/| Visual Studio Keys] (this isn't pirating, Visual Studio is free.)
 
* If you wish, (highly recommended), turn on line numbers by going to Tools > Options > Text Editor > C/C++, and turn on "Line numbers" in the Display subsection.
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Options.png/160581611/Options.png}}]]
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Line_%23.png/160581623/Line_%23.png}}]]
 
* Press File > New > New Project from Existing Code
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/VCStudio_open.png/160580907/VCStudio_open.png}}]]
 
* Choose the folder from your source code folder.
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Select_Source.png/160580971/Select_Source.png}}]]
 
* Choose Windows application project and leave everything unchecked. Press "Next"
 
  *  [[image| {{http://the-powder-toy.wikispaces.com/file/view/Leave_it.png/160581009/Leave_it.png}}]]
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Leave_it_again.png/160581019/Leave_it_again.png}}]]
 
* Leave these boxes blank and press "Next", then "Finish".
 
* Go to Project > Properties > Configuration Properties > Linker > Input.
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Properties.png/160581103/Properties.png}}]]
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Linker_Input.png/160581133/Linker_Input.png}}]]
 
* Open the drop down menu under "Additional Dependencies," click edit, and enter the following text:
 
 
 
shell32.lib
 
  
ws2_32.lib
+
* Under "Code Generation", open up the drop-down menu for "Floating Point Model" and set it to Fast. (this'll get you a noticeable speed improvement)
  
wsock32.lib
+
* Go to Configuration Properties > Linker > Input.
  
"<source>\Libraries\SDL.lib"
+
* Open the drop down menu for "Additional Dependencies," click "<Edit...>", and enter the following text (if you're using the static libraries, you'll have to use the list from the "Linker libraries.txt" file located in the zip file with the libraries you downloaded instead of this one below):
 +
 
 +
shell32.lib
 +
ws2_32.lib
 +
wsock32.lib
 +
SDL.lib
 +
SDLmain.lib
 +
libbz2.lib
 +
regex.lib
 +
pthreadVC2.lib
 +
lua5.1.lib
 +
libfftw3f-3.lib
  
"<source>\Libraries\SDLmain.lib"
+
* Press OK until you close the project properties.
  
"<source>\Libraries\libbz2.lib"
+
* Hit the F7 key on your keyboard, or click Build > Build Solution.
 +
* 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]
  
And for pthread put all of the .lib's in the Libraries folder and link them.
+
* The resulting executable and its required DLLs can be found in the "Build" folder in your source code directory.
  
    * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Dependencies.png/160581177/Dependencies.png}}]]
+
[[Category:Development]]
    * Remember to change <source> to the full path-name of your source folder.
+
[[Category:Compiling]]
    * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Altered_Dependencies.png/160581235/Altered_Dependencies.png}}]]
 
  * Press OK.
 
* Go to Project > Properties > Configuration Properties > VC++ Directories.
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/VC%2B%2B_Input.png/160582115/VC%2B%2B_Input.png}}]]
 
* Open the drop down menu for Include Directories and add the folders
 
  * <source>\Includes
 
  * <source>\Libraries
 
  * these can be found here: https://powdertoy.co.uk/Download/Source-Required.zip
 
    * Also be sure to link the folder that contains your *.h files (only for V43.0 and later)
 
    * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Includes.png/160582151/Includes.png}}]]
 
    * Once again, remember to change <source> to the full path-name of your source folder.
 
    * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Altered_Includes.png/160582245/Altered_Includes.png}}]]
 
  * Hit OK.
 
* Select the entire solution and press Ctrl+F7 or the green arrow at the top.
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Build.PNG/160582331/Build.PNG}}]]
 
  -. When the error message comes up warning you of a missing DLL, simply go to your regular Powder Toy folder, copy the DLLs from "<source>\Libraries\" into your "<source>\debug" or "<source>\release" folder.
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/Error.png/160582433/Error.png}}]]
 
  * [[image| {{http://the-powder-toy.wikispaces.com/file/view/DLLs.png/160582607/DLLs.png}}]]
 
* If something goes wrong, ask on [https://powdertoy.co.uk/Forum.html| The Powder Toy forums]
 

Latest revision as of 23:16, 21 June 2013

Note: this guide is outdated and will only work for the old c source



Original author: Triclops200

Main contributors: raj.k, HolyExLxF, FacialTurd(Simon), Jacob1

"Small" authors: wikku9 (added quotations marks to Additional Dependecies list and other) ,Pyromaniac555 (fixed lists, checked spelling and grammar, etc. (still checking)), Me4502 (added pthread link)


This guide is for Windows

The Linux guide to setup is here.

Contributors are welcome to port this tutorial to Mac OS X (or improve the existing tutorials).




This is a guide to get you started on coding for The Powder Toy. If you have any questions, just ask in the Discussion section on The Powder Toy forums.

It would help if you have programmed before, but it is fine if you never have.

This takes a while to setup, so be patient and follow the instructions carefully.

Its not recommended to begin coding elements until you are able to compile a clean source.

Good luck!


GitHub Set-up

GitHub set-up can be skipped, just go to 'Visual Studio (Windows)'

Doing these steps in order is highly recommended.


  • Create an account at this site: [[1]].
  • Download and install MySysGit.
  • Download and install SmartGit.
  • Set up SmartGit:
  • Choose Non Commercial so you can get unlimited use.
  • Insert as much information as you can.
  • Your API token is at GitHub.com > Account Settings > Account Admin.
  • Give your email to GitHub (necessary [[2]] under email addresses).
  • Open GitBash (from the first program you installed) and type this then hit enter:
  • ssh-keygen -t rsa -C "<yourgithubusernamewithout<>signs>@github.com"
  • Leave the file location blank when it prompts you.
  • Type a strong passphrase and confirm the passphrase (they will not show up, so don't be surprised it looks blank).
  • Open this with notepad: C:\WINDOWS\Users\<username>\.ssh\id_rsa.pub. Make sure to have the File Type setting on All Files, instead of Text Documents.
  • Go to [[3]] > SSH Public Keys. Copy the entire file contents into the the "Key" box. Make sure you don't add any extra spaces or lines (there IS an extra line at the end, though). Leave the Title text box blank and hit "Add key".
  • Open GitBash and type: $ ssh git@gitbash.com
  • Type your passphrase you made earlier and click Yes. If it doesn't work, try
  • $ ssh git@github.com
  • If it still doesn't work, verify you did step 6 right (set another file location or overwrite).
  • Go to [[4]] and click the "Fork" button. This will create a copy of The Powder Toy in your account.
  • Download the source code.
  • Open SmartGit, and go to File > Clone.
  • Press "Select from GitHub" and choose your repository.
  • If your rsa_pub file (the one you made in step # isn't highlighted and the program asks, choose it.
  • Type in your passphrase if the program prompts you.
  • Choose the directory where you want to store the source files.
  • Congratulations! You now have an easy way to make changes to the code and upload it to GitHub.
  • To make changes and send a request to Simon to have it implemented in the official code, open SmartGit (make sure you've saved your changes in Visual Studio).
  • powder.c and any other files you may have changed should be listed as "Modified".
  • Press "Commit" at the top, list the things you have changed in the text box, and press "Commit".
  • Press "Push" at the top, and press "Push" again.
  • Go to your Powder Toy repository page on GitHub and press "Pull Request" at the top.
  • Send the request to facialturd (Simon's username) and you should be done. Verify that the code has been changed if you like.
  • If Simon decides to accept your request, your code will be in the official Powder Toy source code. Congratulations!



If something goes wrong, go to GitHub forums for git help or ask on The Powder Toy forums for powder toy help.




Visual Studio (Windows)

If you can't be bothered to do any of this yourself, then I have uploaded a complete visual studio 2010 project with source (for v82.0 of Powder Toy). https://www.box.com/s/xzarykzoraiorpi41iy1 It has all the libraries and headers you need to compile this version, it statically links everything so no .dll's needed! Just remember to switch it to release mode for better performance/size.

  • Download Visual C++ 2010 Express because of it's great debugging and auto-code tools. It is completely free.
  • Open Visual Studio. You should register it (you don't have to pay anything; it's free) if you plan on using it for more than 30 days.
  • If you wish, (this should already be on by default), turn on line numbers by going to Tools > Options > Text Editor > C/C++, and turn on "Line numbers" in the Display subsection.
  • Download this: Required Libraries (extract it right into your source code folder) (or, if you want a statically linked version that doesn't need a bunch of DLL files to run, download this, but be warned that these libraries may or may not work, and linking may take a very long time to complete)
  • Press File > New > New Project from Existing Code.
  • Choose the folder from your source code folder.
  • Choose Windows application project and leave everything unchecked. Press "Finish". (You don't need to change any of the other options)
  • 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)
  • Go to Project > Properties.
  • Under Configuration Properties > General:
  • Change Output Directory from
$(SolutionDir)$(Configuration)\

to

$(SolutionDir)Build\

(notice that there is no backslash between "$(SolutionDir)" and "Build\").

  • 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)
  • Under Configuration Properties > VC++ Directories:
  • 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
$(ProjectDir)Includes

(type that exactly -- also note that there is no backslash between "$(ProjectDir)" and "Includes")

  • It's important to make sure, after you click OK to close the "Include Directories" dialog box, that this comes before everything else under "Include Directories" -- otherwise you'll get some nasty errors when you try to compile.
  • Open the drop down menu for Library Directories, click "<Edit...>", and add
$(ProjectDir)Libraries

(note that there is no backslash between "$(ProjectDir)" and "Libraries")

  • Go to Configuration Properties > C/C++.
  • Under "General", open the drop-down menu for "Warning Level" and choose the option to turn off all warnings. (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.)
  • Under "Preprocessor", open the drop-down for "Preprocessor Definitions", click "<Edit...>", and add (if you're using the static libraries, you'll have to use the list from the "Preprocessor definitions.txt" file located in the zip file with the libraries you downloaded instead of this list below):
LUACONSOLE
GRAVFFT
X86
X86_SSE2
  • If for some reason the libfftw3f-3.lib included in the Libraries folder doesn't work (it should), try using this one (and follow the instructions on the site).
  • Under "Code Generation", open up the drop-down menu for "Floating Point Model" and set it to Fast. (this'll get you a noticeable speed improvement)
  • Go to Configuration Properties > Linker > Input.
  • Open the drop down menu for "Additional Dependencies," click "<Edit...>", and enter the following text (if you're using the static libraries, you'll have to use the list from the "Linker libraries.txt" file located in the zip file with the libraries you downloaded instead of this one below):
shell32.lib
ws2_32.lib
wsock32.lib
SDL.lib
SDLmain.lib
libbz2.lib
regex.lib
pthreadVC2.lib
lua5.1.lib
libfftw3f-3.lib
  • Press OK until you close the project properties.
  • Hit the F7 key on your keyboard, or click Build > Build Solution.
  • If something goes wrong (i.e. you get an error of some sort), ask on The Powder Toy forums
  • The resulting executable and its required DLLs can be found in the "Build" folder in your source code directory.