SFML community forums
Help => General => Topic started by: yj1214 on July 29, 2015, 02:02:34 am
-
*EDIT* oops, I accudently posted this in the wrong forum. Does anyone know how to remove or move this post to 'help general forum'? Thanks
I did everything right. I built SFML using Cmake with MSYS configuration. Then I copied exact code from the tutorial which looks like this,
#include <SFML/Window.hpp>
int mian(){
sf::Window window(sf::VideoMode(500, 400), "Window", sf::Style::None);
while(window.isOpen()){
sf::Event event;
while(window.pollEvent(event)){
if(event.type == sf::Event::Closed){
window.close();
}
}
}
return 0;
}
This is my compilation...
g++ -std=c++11 window.cpp -o window.exe -L. -lsfml-main -lsfml-window -lsfml-
system
It gives me this error...
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):(.text.start
up+0xa7): undefined reference to `WinMain@16'
collect2.exe: error: ld returned 1 exit status
make: *** [all] Error 1
What's my problem?
-
You link against sfml-main yet you don't set the sub-system to window. IIRC it's the flag -mwindow
-
No effects...
g++ -std=c++11 window.cpp -o window.exe -L. -mwindows -lsfml-main -lsfml-window -lsfml-system
It gives me the same error...oh and is sfml-main necessary? what does it do?
-
I don't know if is typo but in the code instead of "int main()" is "int mian()".
-
Oh, um... *facepalm...I spent my whole day to find the bug and it was because I misspelled... guess I gotta learn how to spell things. Thanks for the solution!