Linux

Preparation

  • You will need to use CMake in order to build TGUI.
    Depenging on your distro, you can download it as easily as typing the following in the terminal:
    “sudo apt-get install cmake” (Ubuntu) or “sudo pacman -S cmake” (ArchLinux).
    Otherwise, 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.

Installing

Type the following in the terminal in order to install tgui. Of course you will have to be inside the downloaded tgui directory.

cmake .
sudo make install -j6

Using TGUI (CodeBlocks)

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

Add ‘-ltgui’ to the “Linker settings” under “Other linker options”. The order of linking has to be correct: first tgui, then the libraries from sfml, namely graphics, windows and system. (you might also need to add -lGL to the list)

CodeBlocks Linker Settings

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

CodeBlocks Compiler Seach Directories

You should now be able to use TGUI.
To test if it is working, simply take a working example code from sfml, include “TGUI\TGUI.hpp” and change sf::RenderWindow to tgui::Window.

Possible error

It is possible to get the following error when linking to TGUI:
“/pathname/of/program: error while loading shared libraries: libtgui.so: cannot open shared object file: no such file or directory”

If you get this then you did install tgui correctly, but it is not in the shared library cache.
All you have to do is open the terminal, type “sudo ldconfig”, hit enter and type your password.

If that doesn’t solve it then make sure the library was installed to a place where your distro searches for it.
One of the things you could do is add “/usr/local/lib/” (without the quotes) to /etc/ld.so.conf and then run “sudo ldconfig” again.