Difference between revisions of "Codeblocks setup"

From The Powder Toy
Jump to: navigation, search
m (Fixed links.)
(Updated a bit; hopefully the libraries work)
Line 7: Line 7:
 
Environmental variable instuctions by pilojo.
 
Environmental variable instuctions by pilojo.
  
Last modified: 10/28/2011
+
Last modified: 12/05/2011
  
  
This is a guide for compiling using Code::Blocks with MinGW. This guide is targeted to those who are intimidated by the large Visual C++ Express download and is using Windows.
+
This is a guide for compiling using Code::Blocks with MinGW. This guide is targeted to Windows users who are intimidated by the large Visual C++ Express download.
  
 
Note: This tutorial works only in Windows, but will work in Macintosh with minor changes.
 
Note: This tutorial works only in Windows, but will work in Macintosh with minor changes.
  
 
==  MinGW Preparation  ==
 
==  MinGW Preparation  ==
* Download and Install [http://sourceforge.net/projects/mingw/files/Automated%20MinGW%20Installer/mingw-get-inst/| MinGW] using the default settings (Or install C++ compiler also, just to be sure).
+
* Download and Install [http://sourceforge.net/projects/mingw/files/latest/download?source=files MinGW] using the default settings (You can also install the C++ compiler if you feel like it, but it's not necessary).
 
* Add <code>"C:\MinGW\bin"</code> to the PATH environment variable, without quotes.
 
* Add <code>"C:\MinGW\bin"</code> to the PATH environment variable, without quotes.
* Download the following libraries: [http://code.google.com/p/luaforwindows/downloads/list| LuaForWindows,] [http://www.libsdl.org/release/SDL-devel-1.2.14-mingw32.tar.gz| SDL,] [http://gnuwin32.sourceforge.net/downlinks/bzip2-bin-zip.php| bzip2,] [http://gnuwin32.sourceforge.net/downlinks/regex-bin-zip.php| regex,] and [ftp://sourceware.org/pub/pthreads-win32/pthreads-2005-03-08.exe| pthreads-win32.]
 
* Extract the libraries contents C:\MinGW\ so it overlaps the bin, lib, and include folders. Don't do this with LuaForWindows, leave it to the default place.
 
  
 
(If you don't know what an environmental variable is, here is how to get to it.)
 
(If you don't know what an environmental variable is, here is how to get to it.)
Line 27: Line 25:
 
* 5. Second box, scroll down till you see PATH.
 
* 5. Second box, scroll down till you see PATH.
 
* 6. Click PATH, then click Edit.
 
* 6. Click PATH, then click Edit.
* 7. If there is not a semi-colin at the end of the line, add one and then add <code>"C:\MinGW\bin"</code> without quotes.
+
* 7. If there is not a semi-colon at the end of the line, add one and then add <code>"C:\MinGW\bin"</code> without quotes.
 
* 8. Press OK
 
* 8. Press OK
 
* 9. Continue tutorial.
 
* 9. Continue tutorial.
  
 
==  Code::Blocks preparation  ==
 
==  Code::Blocks preparation  ==
* Download and Install Code::Blocks [http://prdownload.berlios.de/codeblocks/codeblocks-10.05-setup.exe| here]
+
* Download and Install Code::Blocks [http://prdownload.berlios.de/codeblocks/codeblocks-10.05-setup.exe here]
 
* In the first run, you will be asked what compiler to use. Select "MinGW" or "GNU GCC Compiler".
 
* In the first run, you will be asked what compiler to use. Select "MinGW" or "GNU GCC Compiler".
 
* Code::Blocks is now ready!
 
* Code::Blocks is now ready!
  
 
==  Preparing the project  ==
 
==  Preparing the project  ==
* Download [https://github.com/FacialTurd/The-Powder-Toy/zipball/master| this] and put it in an empty folder.
+
* Download [https://github.com/FacialTurd/The-Powder-Toy/zipball/master the latest source] and put it in an empty folder.
* Open Code::Blocks
+
* Download [http://min.us/lbdi9Y01cHtOY these libraries] and extract it directly into the source folder.
* Create a new empty project.
+
* Open Code::Blocks.
* Create project in the folder where your source exists. (sometimes it adds to the directory the Project name, if that happens, remove the Project name part from the directory)
+
* Create a new empty project in the folder where your source exists. (sometimes it adds the project name to the directory; if that happens, remove the project name part from the directory)
* In the Management window you will see the project name listed there. Right-click then add files recursively.
+
* In the Management window you will see the project name listed there. Right-click it, click "Add files recursively...", and choose the folder where all of the source files are.
* Click the Select All button
+
* Leave all the checkboxes as they are and click "OK".
* Now, the tricky part. Go to Project -> Build options -> Linker settings. Add the following in the link libraries:
+
* At the very top of the window, next to "Build target:", open the drop-down menu and click "Release". (it probably won't matter because of the next few steps, but it's still a good thing to do)
C:\MinGW\lib\libmingw32.a
 
C:\MinGW\lib\libSDLmain.a
 
C:\MinGW\lib\libSDL.dll.a
 
C:\MinGW\lib\bzip2.lib
 
C:\MinGW\lib\libwsock32.a
 
C:\MinGW\lib\libws2_32.a
 
C:\MinGW\lib\libregex.dll.a
 
C:\Program Files\Lua\5.1\lib\lua5.1.lib
 
C:\MinGW\lib\libpthread.dll.a
 
  
* Next, paste this into Other Linker Options, to the right of link libraries:
+
* Go to Project -> Properties -> Build targets, and for every build target on the left, find the drop-down menu on the right next to "Type:" and change it from "Console Application" to "GUI Application". (You don't have to, but it's a good idea to do so.)
  
-static-libgcc -static-libstdc++
+
* Go to Project -> Build options -> Compiler Settings.
 +
* Under Compiler Flags, make sure that everything is unchecked.
 +
* Under Other Options, type in
 +
-w -m32 -std=c99 -mincoming-stack-boundary=2 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -DGRAVFFT -D_GNU_SOURCE -DWIN32
 +
-Ofast -ffast-math -ftree-vectorize -funsafe-math-optimizations -march=native -mtune=native -DX86 -DX86_SSE2 -msse2
 +
* Typing -DGRAVFFT in the above line is optional and gives a significant speed boost to gravity calculations, but increases the executable size greatly (by as much as 36%).
  
* Now go to Search directories -> Compiler, still in Build Options. Add the following:
+
* Go to the Search Directories tab at the top of the build options window.
 +
* Under the Compiler tab, click Add, and browse to and add the "includes" folder of the source to the list. (It should be okay to leave it as a relative path, but if you get a bunch of errors about various .h files not being found, try using the full path of the includes folder.)
 +
* Under the Linker tab, click Add, and add the "lib" folder of the source to the list. (as with the includes folder, you may or may not have to use the full path of the lib folder.)
  
includes* (note: if you get air.h not found, try adding the full path to the includes folder)
+
* Now go to the Linker Settings tab at the top of the build options window.
C:\MinGW\include\SDL
+
* Under "Other Linker Options", type in
C:\MinGW\include\
+
  -s -static -lmingw32 -lregex -lws2_32 -lSDLmain -lSDL -luser32 -lgdi32 -lwinmm -lpthread -lfftw3f -lm -lbz2
 
+
-llua5.1 -mwindows
* The last one. In Compiler Settings -> Other options, still in Build Options, Add the line:
+
* If you didn't bother with adding -DGRAVFFT to the compiler options, you can remove "-lfftw3f" from the above line.
  -w -m32 -std=c99 -D_POSIX_C_SOURCE=200112L -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -mmmx -DX86 -mwindows -DWIN32
+
* Hit OK at the very bottom.
  
 
==  Compiling  ==
 
==  Compiling  ==
* Press F9 in your keyboard.
+
* Press Ctrl+F9 in your keyboard.
* It should compile. If not, post in the HELP secton on the forums with a [http://pastebin.com/| pastebin] of your compiling error
+
* It should compile. If not, post in [https://powdertoy.co.uk/Discussions/Categories/Topics.html?Category=5 the forums] with a [http://pastebin.com/ pastebin] of your error(s).
 
* If it compiles continue to the [[Coding-tutorial|element coding tutorial.]]
 
* If it compiles continue to the [[Coding-tutorial|element coding tutorial.]]
  
 
[[Category:Development]]
 
[[Category:Development]]

Revision as of 02:53, 6 December 2011

Author: tian110796

Fixed by macweirdo for Version 47 (Python Console Fixes)

Some parts are from JojoBond.

Environmental variable instuctions by pilojo.

Last modified: 12/05/2011


This is a guide for compiling using Code::Blocks with MinGW. This guide is targeted to Windows users who are intimidated by the large Visual C++ Express download.

Note: This tutorial works only in Windows, but will work in Macintosh with minor changes.

MinGW Preparation

  • Download and Install MinGW using the default settings (You can also install the C++ compiler if you feel like it, but it's not necessary).
  • Add "C:\MinGW\bin" to the PATH environment variable, without quotes.

(If you don't know what an environmental variable is, here is how to get to it.)

  • 1. Go to My Computer.
  • 2. System properties/settings.
  • 3. Advanced system settings.
  • 4. Environmental Variables.
  • 5. Second box, scroll down till you see PATH.
  • 6. Click PATH, then click Edit.
  • 7. If there is not a semi-colon at the end of the line, add one and then add "C:\MinGW\bin" without quotes.
  • 8. Press OK
  • 9. Continue tutorial.

Code::Blocks preparation

  • Download and Install Code::Blocks here
  • In the first run, you will be asked what compiler to use. Select "MinGW" or "GNU GCC Compiler".
  • Code::Blocks is now ready!

Preparing the project

  • Download the latest source and put it in an empty folder.
  • Download these libraries and extract it directly into the source folder.
  • Open Code::Blocks.
  • Create a new empty project in the folder where your source exists. (sometimes it adds the project name to the directory; if that happens, remove the project name part from the directory)
  • In the Management window you will see the project name listed there. Right-click it, click "Add files recursively...", and choose the folder where all of the source files are.
  • Leave all the checkboxes as they are and click "OK".
  • At the very top of the window, next to "Build target:", open the drop-down menu and click "Release". (it probably won't matter because of the next few steps, but it's still a good thing to do)
  • Go to Project -> Properties -> Build targets, and for every build target on the left, find the drop-down menu on the right next to "Type:" and change it from "Console Application" to "GUI Application". (You don't have to, but it's a good idea to do so.)
  • Go to Project -> Build options -> Compiler Settings.
  • Under Compiler Flags, make sure that everything is unchecked.
  • Under Other Options, type in
-w -m32 -std=c99 -mincoming-stack-boundary=2 -D_POSIX_C_SOURCE=200112L -DLUACONSOLE -DGRAVFFT -D_GNU_SOURCE -DWIN32
-Ofast -ffast-math -ftree-vectorize -funsafe-math-optimizations -march=native -mtune=native -DX86 -DX86_SSE2 -msse2
  • Typing -DGRAVFFT in the above line is optional and gives a significant speed boost to gravity calculations, but increases the executable size greatly (by as much as 36%).
  • Go to the Search Directories tab at the top of the build options window.
  • Under the Compiler tab, click Add, and browse to and add the "includes" folder of the source to the list. (It should be okay to leave it as a relative path, but if you get a bunch of errors about various .h files not being found, try using the full path of the includes folder.)
  • Under the Linker tab, click Add, and add the "lib" folder of the source to the list. (as with the includes folder, you may or may not have to use the full path of the lib folder.)
  • Now go to the Linker Settings tab at the top of the build options window.
  • Under "Other Linker Options", type in
-s -static -lmingw32 -lregex -lws2_32 -lSDLmain -lSDL -luser32 -lgdi32 -lwinmm -lpthread -lfftw3f -lm -lbz2
-llua5.1 -mwindows
  • If you didn't bother with adding -DGRAVFFT to the compiler options, you can remove "-lfftw3f" from the above line.
  • Hit OK at the very bottom.

Compiling