Codeblocks setup

From The Powder Toy
Revision as of 12:45, 28 October 2011 by Fast-Driver (talk | contribs) (MinGW Preparation)
Jump to: navigation, search

Author: tian110796

Fixed by macweirdo for Version 47 (Python Console Fixes)

Some parts are from JojoBond.

Environmental variable instuctions by pilojo.

Last modified: 5/21/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.

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

MinGW Preparation

  • Download here and install MinGW using the default settings (Or install C++ compiler also, just to be sure).
  • Add C:\MinGW\bin; to the PATH environment variable
  • Download SDL here and bzip2 here and regex here
  • Extract the folders in these files to C:\MinGW\ so that it coincides to the bin, lib, and include folders of the MinGW installation.

(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 no " ; " at the end of the line, add one and then add C:\MinGW\bin; .
  • 8. Hit ok
  • 9. Continue tutorial.

Code::Blocks preparation

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

Python Preparation

Preparing the project

  • Create a new empty project.
  • 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)
  • In the Management window you will see the project name listed there. Right-click then add files recursively.
  • Click the Select All button
  • Now, the tricky part. Go to Project -> Build options -> Linker settings. Add the following in the link libraries:

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:\Python27\libs\python27.lib

C:\MinGW\lib\libpthread.dll.a

  • Next, paste this into Other Linker Options, to the right of link libraries:

-static-libgcc -static-libstdc++

  • Now go to Search directories -> Compiler, still in Build Options. Add the following:

includes* (note: if you get air.h not found, try adding the full path to the includes folder)

C:\MinGW\include\SDL

C:\MinGW\include\

  • The last one. In Compiler Settings -> Other options, still in Build Options, Add the line:

-w -m32 -std=c99 -D_POSIX_C_SOURCE=200112L -O3 -ffast-math -ftree-vectorize -funsafe-math-optimizations -mmmx -DX86 -mwindows -DWIN32

Compiling

  • Press F9 in your keyboard.
  • It should compile. If not, post in the HELP secton on the forums with a paste bin of your compiling error
  • If it compiles continue to the element coding tutorial.