Build the Nero Hello WorldHi everyone, how are doing
.
In this post I'm going to show how to build and run the Engine, The goal will be to make the following snippet of code work.
#include <NERO/engine/DevEngine.h>
int main()
{
nero_log("Nero game engine Hello World");
nero::DevEngine engine;
engine.run();
}
This tutorial will focus on Windows, CodeBlocks and MinGW, if you are familiar with other tools, I'm sure you will find your way out too. Also I will asume that you know a bit of Cmake GUI
Step 1 : Download the SourcesAll the sources are available on github
Boost 1.61.0 :
https://github.com/boostorg/boostBox2D 2.3.0 :
https://github.com/erincatto/Box2DSFGUI 0.3.1 :
https://github.com/TankOs/SFGUISFML 2.4.0 :
https://github.com/SFML/SFMLNero 0.7.0 :
https://github.com/NeroGames/nero-game-engineThe Nero project use a specific version of the others libraries, you may try to use the latest version of the corresponding libraries, but for this tutorial I will stay with the specific versions in order to avoid any incompatibilities.
After downloading SFML, SFGUI, Boost and Box2D, you will have to checkout the sources in order to get the right version.
It's pretty easy. Here is a exemple with SFML
git clone https://github.com/SFML/SFML.git // Download the SFML source code (latest version)
cd SFML // Move to the SFML source directory
git tag -l // Display all the available versions
git checkout tags/2.4.0 // Switch the code to the version 2.4.0, the command is " git checkout tags/<tag_name> "
And there it is, you now have the SFML 2.4.0 version, you can do the same for Boost, Box2D, and SFGUI
Step 2 : Build the SourcesBuild BoostLet's begin by the easiest one, we are going to build only the
system and the
filesystem libs.
for that, move into the boost source directory and issue the following two commands one after another
./bootstrap.sh./b2.exe --prefix=build --with-filesystem --with-system link=shared variant=debug,release threading=multiThe result of the build will be in the folder
stage/libBuild Box2D, SFML and SFGUIBox2D, SFML and SFGUI can be build easly with Cmake GUI
SFGUI depends of SFML, if Cmake does not find SFML, you can define the
Path option
SFML_ROOT.
the sfml root directory should look like this
sfml_root_path/inlcude/SFML //contains the sfml headers
sfml_root_path/lib //constains the sfml libs (.a files with MinGW)
Step 3 : Build NeroAfter building Boost, Box2D, SFML and SFGUI you can now build the Nero project using Cmake GUI.
If Cmake does not find boost, you can define the
Path option
BOOST_ROOTthe boost root directory should look like this
boost_root_path/inlcude/boost //contains the boost headers
boost_root_path/lib //constains the boost libs (.a files previously build)
If Cmake does not find SFML, you can Define the path option
SFML_ROOT like for SFGUI
If Cmake does not find Box2D or SFGUI you will have to configure manually the following cmake options.
BOX2D_INCLUDE_DIR
BOX2D_LIBRARY_DEBUG
BOX2D_LIBRARY_RELEASE
SFGUI_INCLUDE_DIR
SFGUI_LIBRARY_DEBUG
SFGUI_LIBRARY_RELEASE
If you have built Box2D and SFGUI in Release and Debug mode, you can provide the two libs version, if not, providing either the Debug or Release libs will be enough.
Step 4 : Organise your LibsWhen you build a library you can choose where the libs will be install. Libraries like Boost have default installation path, so cmake or any IDE or compiler can find them easily. Personnaly I use a custom folder call "Library" to store all my libs. It's easy to find them if I know they are all in one place. Choose the method that suits you the best.
In the next section I will assume that you have all the libs in a folder "Library" like this:
Library/include //contains all the libraries headers
Library/inlcude/SFML
Library/inlcude/Box2D
Library/inlcude/SFGUI
Library/inlcude/boost
Library/inlcude/json // This one can be find in the Nero project source files, under the "extlibs" directory
Library/inlcude/easyloggingpp // "extlibs" directory also
Library/lib // contains all the libraries libs (.a files with MingW)
Library/bin // conatains all the DLL files
Library/doc // the libs doc
Step 5 : Link the lilbrariesNow that you have all the libs and DLL ready, you can create a new Project and make the following configurations.
On CodeBlocks, all of this is done in (Project --> Build Options)
activate the c++11 flag (Project --> Build Options --> Compiler Settings --> Compiler flags)
add the headers path "Libray/include" (Project --> Build Options --> Search directories --> Compiler)
add the libs path "Library/lib" (Project --> Build Options --> Search directories --> Linker)
add the dll path "Library/bin" (Project --> Build Options --> Search directories --> Linker)
link all the libs (Project --> Build Options --> Linker settings --> Link libraries
and/or --> Other linker options)
Step 6 : Mandatory directoriesAfter linking the libs, there is one more thing to do, the Engine expect some directories and files to be available.
Resource/
Resource/Texture/
Resource/Font/
Resource/Font/Sansation.ttf //
This is one is important, the Engine use it for text renderingconfig/
config/log_config //Pretty important, but not necessary
You can download those directories here :
https://github.com/NeroGames/resource-pack/blob/master/Directory.zipUnzip the file and copy its content in your project directory
That's AllThis post described all the steps you'll need to get start with the Engine. Build and Link libraries is one of the most difficult part when working on C++ programs. It may give you some headaches
. So try again and again if it does not work and feel free to ask any question in case of difficulties.