Hi there,
I'm trying to compile some SFML C++ code on Windows 10 with Visual Studio Code and I keep having that mistake. I'm running VSCode tasks to compile and link SFML library with g++ and while compilation (g++ -IC:\lib\SFML\include -c main.cpp -o main.o) has no problem I'm getting that error whenever I try to link the libraries (g++ -LC:\lib\SFML\lib -o GUImeOfLife.exe -o main.o -lsfml-graphics -lsfml-window -lsfml-system) as indicated in the tutorial on how to compile with g++ (a little different of course since I'm doing it on Windows)
C:/TDM-GCC-32/bin/../lib/gcc/mingw32/5.1.0/../../../libmingw32.a(main.o):main.c:(.text.startup+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
The terminal process terminated with exit code: 1
I've looked on the internet for quite some time now and apparently it can happen when there is no main.cpp file or main or WinMain function to compile but I've triple checked my code and even tried to replace main with WinMain or even to add the "argc" and "argv" arguments to my function but it won't fix my problem.
Here's my main.cpp code to review
#include <SFML/Graphics.hpp>
int main(int argc, char *argv[])
{
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;
}
Could the fact that I'm working on VSCode have any impact on that ?
I have to have SFML working by the end of the week for a school project so if anyone could help me figure this out I'd be the happiest man on earth
Thanks