I installed Visual Studio Code yesterday, and I’m trying to set up SFML. This is the link to the Youtube video I’m following: https://www.youtube.com/watch?v=rZE700aaT5I (timestamp: 05:17)
The following code block is what I have in my main.cpp so far. I got this code from the SFML website. Here’s the link for your reference: https://www.sfml-dev.org/tutorials/2.6/start-linux.php
#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;
}
Here’s what I typed in the terminal so far. Please remember that I replaced with the correct path.
- g++ -c main.cpp -I/include (this made a main.o)
- g++ main.o -o sfml-app -L/lib -lsfml-graphics -lsfml-window -lsfml-system
After I press enter after 2, I get a message saying,
c:/mingw/bin/../lib/gcc/mingw32/6.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16′
Youtube and Stack Overflow offered a few reasons/solutions:
- I don’t have a main(), so create a main().
-> I have a main(), so I don’t think this is the issue. - I didn’t save before running.
-> I initially did not save before running and thought this was the problem. However, I Ctrl+S and ran it, and I’m still getting this issue. I also went to Settings, and searched up ‘Code runner’ and ‘Save all” to see if the Code-runner:Save All Files Before Run was checked off, and I don’t even see that on my screen. - Add -mwindows at the end (so I would type g++ main.o -o sfml-app -L/lib -lsfml-graphics -lsfml-window -lsfml-system -mwindows)
-> This also did not work, and I’m running into the same issue. - Double-check the path.
-> I did, and it’s the correct path.
What am I missing out on? Also, I’m new to VS Code and SFML, so please be patient with me.
abc is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.