Visual Studio

TGUI requires a compiler that supports c++11. This means that you need at least the VC++10 compiler (Visual Studio 2010).

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. I am using the Visual Studio 2008 in this example.
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 (not SFMLDIR like in older versions) 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 three things:

  • You probably need to place the lib folder there yourself, with the libraries that you have build.
  • This folder must contain the libraries directly (not inside a Debug or Release folder).
  • 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. This option must match with the one you must select in Visual Studio later.
  • TGUI_USE_STATIC_STD_LIBS must match the corresponding option in sfml and should thus be left FALSE unless you know what you are doing.

Visual Studio

You are not done yet.
CMake made a Visual Studio project in the build directory that has to be build first.
Simply open the tgui.sln file, set the configuration to Debug or Release and then hit “Build Solution”.

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.

To make it easier to use tgui in your project, you should copy the libraries to the same folder.
I would advice to make a lib folder in the tgui root directory and place the libraries there.

Using TGUI

Open the Project Properties.

Visual Studio Project Properties

In both debug and release mode, add the include and library directories.

Visual Studio Additional Include Directories
Visual Studio Additional Library Directories

In both debug and release mode (this time seperately), you must add the library to link with.
When linking statically it will of course become tgui-s.lib and tgui-s-d.lib.
The order of linking is also important: first sfml, then tgui.

Visual Studio Additional Dependencies
Visual Studio Additional Dependencies

When linking dynamically, don’t forget to copy the needed dlls to the directory where your compiled executable is.

You should now be able to use TGUI.