Sign in to follow this  
nicforte

SFML stumbling block

Recommended Posts

Hi new here,

 

I'm an amateur who is attempting to create a game out of personal interest. I have worked my way to the c++ programming level of creating some reasonably detailed games to which I would like to add some simple 2D sprite graphics. I have read that SFML is probably the best option for me at this point.

 

The problem I am having is that after adding on SFML and attempting a very simple program, (for instance the demo which creates a window and draws a green circle in it), I get a crash. Here are the details I have so far:

 

- I am running CodeBlocks 12.11 with MinGW, and sfml 2.0, (but I have also tried with 1.6)

-This is the demo program straight from sfml website, I copied it directly and pasted it into Codeblocks

 

#include <SFML/Graphics.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;
}

 

 

- compiler gives me no errors

- i get this error from windows when the program is run "sfmlTest.exe has stopped working", sfmlTest.exe being the executable for the program I created

 

- debug gives me this:

 

Unhandled exception at 0x691C4AF9 (sfml-window-2.dll) in finalsfml2.exe: 0xC0000005: Access violation writing location 0x000000C8.

 

and

 

Unhandled exception at 0x772D016E (ntdll.dll) in finalsfml2.exe: 0x00000000: The operation completed successfully.

 

 

 

I've tried deleting everything and reinstalling.  I have made absolutely certain to make sure all linking was done correctly (I have done it over and over again just to make sure).  I have made sure to include .dll files in the same directory as the execute file.  These are all the options that have been suggested to me in other forums but none have been successful.  I have also attempted other similar small programs with sfml features and I end up with the same problem.

 

Any help would be appreciated.

Edited by nicforte

Share this post


Link to post
Share on other sites

A shot in the dark: what version of MinGW do you use (there might be ABI incompatibity). Did you try to use a self compiled version of SFML? (just to ensure that everything is compiled with the same compiler)

Share this post


Link to post
Share on other sites
With which compiler were the DLLs created? What were the build settings used? Usually people will build using a shared runtime and I have seen similarly cryptical errors before when missing a runtime. Note that the runtime your compiler uses and the one the DLLs you are using requires do not have to be the same version.

Also note that being able to use different runtimes in DLLs and the main program requires design decision made by the library creator. I cannot answer right away if SFML would work in such a scenario at all. If the documentation does not definitively answer that question I would suggest you build SFML yourself - runtime problems like that often won't crash obviously but instead cause subtle and difficult to detect problems.

Share this post


Link to post
Share on other sites

Wow, when people said game programming was hard I had no idea these would be the types of pitfalls that awaited me.  Well it looks like I have a lot of reading to do.

Edited by nicforte

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this