Public Group

# SFML crash on startup w/ MinGW

This topic is 1955 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

So after programming a while in Allegro 4 I finally came to the realization that it's outdated and probably not the best thing to be coding in ^_^; So I installed SFML in CodeBlocks, but now it's acting weird, giving me a: "SFMLtest.exe has stopped working" when I try to pull up any sort of window with it. Any ideas? I'm sure there's an easy fix in this, just everything I've tried so far has failed.

##### Share on other sites
Post your code. Also, what does a debug stack trace tell you?

##### Share on other sites

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()"

##### Share on other sites

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.

Edited by Crusable

##### Share on other sites

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.

##### Share on other sites

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.

##### Share on other sites

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.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
17
5. 5

• 9
• 12
• 9
• 33
• 13
• ### Forum Statistics

• Total Topics
632591
• Total Posts
3007250

×