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
- sudo apt-get install libsfml-dev
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
- g++ -c main.cpp
- g++ main.o -o sfml-app -L /usr/include/SFML/lib -lsfml-graphics -lsfml-window -lsfml-system
- ./sfml-app
but nothing shows up. It's stuck on a loop.
Troubleshooting I have tried to run instead
- g++ main.o -o sfml-app -L /usr/include/SFML/ -lsfml-graphics -lsfml-window -lsfml-system
I have further tried to manually download the .gz file, extracted it and used instead
- g++ main.o -o sfml-app -L C:/Users/mihail/Documents/SFML/SFML-2.5.1/lib -lsfml-graphics -lsfml-window -lsfml-system
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 :
/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.