Compilation CodeBlocks Windows - wokste/bamengine GitHub Wiki
Note: Compilation is quite more complex than the binary installation. If you just want to play the game, you may be able to use a precompiled binary.
Steps
- Install IDE
- Set up filestructure
- Download external libraries
- Create the project
- Build
It is recommended to use GCC 4.8 or later as a compiler, because it supports C++11. At the moment of writing, the visual studio compiler does not yet support constexpr and certain string manipulation functions, that are required for certain external libraries. Therefore, Visual Studio is currently not supported. Compiling with clang should work but is untested.
For windows development, I advise the codeblocks-13.12mingw-setup-TDM-GCC-481.exe download of Code::Blocks (http://www.codeblocks.org/ ). Other IDE's may work as well, but may require some different settings.
Make the following file structure for the project. Clone the git repository and copy the data directory from a binary release to this directory.
The following libraries have to be downloaded.
external/ # All code not from the repository
libnoise/ # Library for noises. This is primary used to generate the heightmap. Download from (http://libnoise.sourceforge.net/)
SFGUI-0.2.0/ # Library for the gui. Download from (http://sfgui.sfml-dev.de/)
SFML-2.1/ # Graphics library. Download from (http://www.sfml-dev.org/)
For SFML make sure you are downloading a version with DLLs compatible with the GCC version of Code::Blocks. For me this was “GCC 4.7 TDM (SJLJ) - 32 bits” vesion.
For the debug files of SFGUI and the files from libnoise you may need to compile the code yourself.
Get the latest source from github. It is best to fetch it using git if you are likely to make any contribution.
Create an empty project, for example in the root directory of the project. Use the standard setting for the GCC compiler.
Right-click the project icon and choose "add files recursively". This will give a pop-up. Add all files in src/
to the project. External libraries do not need to be added.
Right-click the project and choose "Build options". This will give a pop-up. Under the "Compiler Settings" tab, check: -std=C++11
. This will enable the features of C++11. Make sure it is applied to both debug and release.
Go to the linker settings tab and add the following link libraries: opengl32
, glu32
, sfml-graphics
, sfml-window
, sfml-system
and 'sfgui'. This tells the linker that it should link against those libraries. In the next steps we will inform the project where it can find those files. (If compiling under Linux, you need to use GL
instead of opengl32
and GLU
instead of glu32
.)
In the search directories, you need to add a <extern dir>/SFML-2.1/include/
, <extern dir>/libnoise/include
and <extern dir>/SFGUI-0.2.0/include
to the compiler directories. This makes it possible for the compiler to find the required SFML files with the include statement.
Add <extern dir>/SFML-2.1/include/
and <extern dir>/libnoise/bin/release
to the linker directories. (The linker directories can also be found on the search directory tab)
You can optionally set the define NDEBUG in the release mode. This makes the main function capture any exception and shows an error message on the screen instead of activating the debugger.
You should now be able to build your project.