CodeBlocks

CMake

  • You will need to use CMake in order to build TGUI. You can download the latest version here.
  • Also make sure that you already have sfml on your computer. It would be even better to make sure you have sfml working before trying to use TGUI. If something goes wrong afterwards, you can be sure that the problem does not lie with sfml.
  1. Set the pathname to the TGUI folder that you downloaded.
  2. Set a folder to build TGUI in, usually a new empty folder in the same directory as (1).
  3. Press this button to start configuring.
CMake Build Directory

Next select your compiler.
Just keep the “Use default native compilers” option checked and ignore the other three options.

CMake Select Compiler

It is possible that CMake will not be able to find sfml and will give you an error.
You will then have to tell CMake where it needs to search for sfml. Change the SFML_ROOT to the correct path. This will be the root path of sfml, which contains the include and lib folders.

When you compiled sfml yourself then you will have to watch out for two things:

  • You probably need to place the lib folder there yourself, with the libraries that you have build.
  • If you use static linking then the folder must of course contain the static sfml libraries.
CMake SFML not found

Now you can also change the other options. At the end of this CMake part, you can find the explanation of some of the options. Once you are done, you need to press Configure again.

After you pressed configure, you should have reached the message “Configuring done” at the bottom.
All you have to do now is press Generate.

CMake Generate

Some last notes about CMake:

  • The TGUI_SHARED_LIBS option has to match the one from sfml.
  • If you use the static sfml libraries (the ones that have “-s” in their names) then you should uncheck this option.
  • The CMAKE_BUILD_TYPE can be Release or Debug.

CodeBlocks

You are not done yet.
CMake made a CodeBlocks project in the build directory that has to be build first.
Simply open the “tgui.cbp” file and then hit “Build”.

When this is done you should find the tgui(-d).lib and tgui(-d).dll inside the lib folder.
If you chose to build statically then you will of course only find a tgui-s(-d).lib file.

Using TGUI

Open the “Project build options” and choose whether you want to change debug or release target settings. Or you can just click on the name of your project (here TGUI_Test) and set them for both.

CodeBlocks Project Build Options

In the “Search directories” of the “Compiler” add the path to tgui.

CodeBlocks Search Directories Compiler

In the “Search directories” of the “Linker” add the path to the tgui libraries.

CodeBlocks Search Directories Linker

In ‘Release’ settings, add ‘-ltgui’ to the “Linker settings” under “Other linker options”.
In ‘Debug’ settings, add ‘-ltgui-d’ to the “Linker settings” under “Other linker options”.
When linking statically, you have to use ‘-ltgui-s’ and ‘-ltgui-s-d’ of course.
The order of linking has to be correct: first tgui, then the libraries from sfml, namely graphics, windows and system.

CodeBlocks Linker Settings

You must also enable c++11.
If you have an older compiler version and don’t have the “-std=c++11″ option, then use “-std=c++0x” instead.

CodeBlocks Compiler Flags

When using shared libraries, don't forget to copy tgui.dll to your project’s folder.

You should now be able to use TGUI.