Trouble Using TGUI with SFML in C++ Project in Visual Studio 2022


I’m trying to integrate SFML and TGUI libraries into my C++ projects. While SFML works perfectly, I’m having trouble with TGUI.

I followed the installation instructions on the TGUI website carefully—adding the necessary directories and setting the appropriate properties in Visual Studio. However, I get an error when running the following code:

#include <SFML/Graphics.hpp>
#include <TGUI/TGUI.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "TGUI Example");
    tgui::Gui gui(window);

    // Other GUI setup code here

    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            gui.handleEvent(event);
            if (event.type == sf::Event::Closed)
                window.close();
        }

        window.clear();
        gui.draw();
        window.display();
    }

    return 0;
}

I’ve double-checked that the TGUI library is included correctly, but I’m at a loss for what could be going wrong.

Does anyone have any suggestions or solutions?

I tried pretty much everything I could. Double-Checking if I pasted the right directories (I did according to the TGUI installation guide) and also the Visual Studio project include properties (which also are correct) but this error doesn’t seem to go away.

Edit: I checked, and the error message is coming from IntelliSense in Visual Studio. The exact error message is:

Severity: Code  
Description: Namespace "tgui" does not have a member "Gui".  
Project: PhyEng  
File: C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp  
Line: 7

The build log says the following at the end:

The build started at 17:37...
1>------ Build started: Project: PhyEng, Configuration: Debug x64 ------
1>Main.cpp
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(9,11): error C2039: 'Gui' is not a member of 'tgui'.
1>    C:\Users\Admin\Desktop\RandProj\PhyEng\include-tgui\TGUI\Widgets\VerticalLayout.hpp(32,30):
1>    See declaration of 'tgui'
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(9,11): error C2065: 'Gui': undeclared identifier
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(9,15): error C2146: syntax error: missing ';' before identifier 'gui'
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(9,15): error C3861: 'gui': identifier not found.
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(15,5): error C2065: 'gui': undeclared identifier
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(20,5): error C2065: 'gui': undeclared identifier
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(34,13): error C2065: 'gui': undeclared identifier
1>C:\Users\Admin\Desktop\RandProj\PhyEng\PhyEng\Main.cpp(38,9): error C2065: 'gui': undeclared identifier
1>The build of the project 'PhyEng.vcxproj' is complete -- ERROR.

Leave a Reply

Your email address will not be published. Required fields are marked *