SFML community forums

Help => General => Topic started by: physicskush on January 05, 2022, 11:10:28 pm

Title: Running the minimal example for WSL Ubuntu Subsystem in VS Code
Post by: physicskush on January 05, 2022, 11:10:28 pm
I am running a WSL 2 Ubuntu Windows subsystem in VS Code and I am trying to run the Linux Minimal example.

I performed the following operations
which successfully installed SFML in /usr/include/SFML wherein resides ./Audio , ./Window , etc.

Then on my c++ project on VS Code, inside the main.cpp file I have the minimal example code :
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);

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

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

    return 0;
}
 

I then perform
but nothing shows up. It's stuck on a loop.

Troubleshooting
I have tried to run instead
I have further tried to manually download the .gz file, extracted it and used instead

but nothing really works, it's always stuck and doesn't show the window.

Also, besides the /usr/include/SFML folder that I'm using, I get this additional folders when I run dpkg -L libsfml-dev :
Code: [Select]
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/cmake
/usr/lib/x86_64-linux-gnu/cmake/SFML
/usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfig.cmake
/usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfigDependencies.cmake
/usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLConfigVersion.cmake
/usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLSharedTargets-none.cmake
/usr/lib/x86_64-linux-gnu/cmake/SFML/SFMLSharedTargets.cmake
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/sfml-audio.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/sfml-graphics.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/sfml-network.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/sfml-system.pc
/usr/lib/x86_64-linux-gnu/pkgconfig/sfml-window.pc
/usr/share
/usr/share/doc
/usr/share/doc/libsfml-dev
/usr/share/doc/libsfml-dev/copyright
/usr/lib/x86_64-linux-gnu/libsfml-audio.so
/usr/lib/x86_64-linux-gnu/libsfml-graphics.so
/usr/lib/x86_64-linux-gnu/libsfml-network.so
/usr/lib/x86_64-linux-gnu/libsfml-system.so
/usr/lib/x86_64-linux-gnu/libsfml-window.so
/usr/share/doc/libsfml-dev/changelog.Debian.gz
_______

Could anyone help understand what I am doing wrong ? Thank you very much for your time.
Title: Re: Running the minimal example for WSL Ubuntu Subsystem in VS Code
Post by: physicskush on January 05, 2022, 11:57:41 pm
solved -> Had to turn xServer via xLaunch  :D