Jump to content
  • Advertisement
Sign in to follow this  
JackDigbug

SFML crash on startup w/ MinGW

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!