Compiling tpt with Visual Studio (old)

From The Powder Toy
Revision as of 19:28, 28 September 2011 by Simon (talk | contribs) (1 revision)
Jump to: navigation, search

Setting up GitHub and Visual Studio for Coding

Original author: Triclops200

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

"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 GNU/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 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 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 :)

Download Pthread here ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-8-0-release.exe

<source> should be replaced by the appropriate folder where the source code is located!


  • Visual Studio Express 2010 C++ because of it's great debugging and auto-code tools. It is completely free.
  • Open Visual Studio. If you didn't get a product key, go to 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| Template:Http://the-powder-toy.wikispaces.com/file/view/Options.png/160581611/Options.png]]
 *  {{http://the-powder-toy.wikispaces.com/file/view/Line_%23.png/160581623/Line_%23.png}}
  • Press File > New > New Project from Existing Code
 * [[image| Template:Http://the-powder-toy.wikispaces.com/file/view/VCStudio open.png/160580907/VCStudio open.png]]
  • Choose the folder from your source code folder.
 * [[image| Template: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| Template:Http://the-powder-toy.wikispaces.com/file/view/Leave it.png/160581009/Leave it.png]]
 * [[image| Template: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| Template:Http://the-powder-toy.wikispaces.com/file/view/Properties.png/160581103/Properties.png]]
 * [[image| Template: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

wsock32.lib

"<source>\Libraries\SDL.lib"

"<source>\Libraries\SDLmain.lib"

"<source>\Libraries\libbz2.lib"

And for pthread put all of the .lib's in the Libraries folder and link them.

   * [[image| Template:Http://the-powder-toy.wikispaces.com/file/view/Dependencies.png/160581177/Dependencies.png]]
   * Remember to change <source> to the full path-name of your source folder.
   * [[image| Template: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.
 *  {{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| Template: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| Template: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| Template: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| Template:Http://the-powder-toy.wikispaces.com/file/view/Error.png/160582433/Error.png]]
 * [[image| Template:Http://the-powder-toy.wikispaces.com/file/view/DLLs.png/160582607/DLLs.png]]