SFML crash on startup w/ MinGW
Sorry, was at school
#include <iostream>
#include <SFML/graphics.hpp>
#include <SFML/window.hpp>
#include <SFML/system.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;
}
Debug says under function
"sf::Window::Window() ()
0x003e3104 in ??()
__mingw_CRTStartup()
mainCRTStartup()"
You do not need to include system and window if you include graphics. I tried it out and it works in VS2012. Maybe you installed it wrong.
Didn't realize the include thing, cool
Yeah I'm sure it's installed wrong somehow, but I can't see where I went wrong. I did everything right out of the documentation and double checked it.
Do a debug build, link to the debug libraries, and see what a (good) backtrace will tell you.
Also, what download package are you using? I haven't used SFML in awhile, and always built it from source, but looking at the download page I see that they officially released 2.0 finally, and they have several different downloads available. Of particular interest for you (using MinGW as you are) are the packages labeled GCC 4.7 TDM (SJLJ) and GCC 4.7 MinGW (DW2). There is a potential trap lurking here that you possibly might not be aware of.
You see, if you are using CodeBlocks, then it is possible that you installed the version of MinGW that comes bundled with the codeblocks installer. This version would be GCC 4.7 TDM, which uses SJLJ (set ump long jump) for exception handling. If this is the case, then be warned that the MinGW (DW2) version of SFML won't work, since it uses Dwarf-2 exception handling. Correspondingly, if you didn't install bundled TDM GCC with CodeBlocks, but instead installed a build from MinGW itself, then you would want to install the MinGW (DW2) version and not the TDM GCC (SJLJ) version since most non-TDM builds of MinGW use DW2.
I can't say if this is your issue or not, but it is a potential pitfall that can be a little harder to sort out if you are not aware of the differences between exception handling mechanisms.
If you are still having issues after going through everything JTippetts mentioned, it might be a good idea to post your problem directly to the SFML forums. They are generally pretty helpful with getting people up and running.