Question

I just installed the newest version of CodeBlocks (13.12 with TDM-GCC-4.8.1) and now my code doesn't work. In the older version that I had, everything compiled and ran flawlessly, but now, using the same code, it compiles but crashes at run-time saying that my program "has stopped working", and returns -1073741510 (0xC0000005).

I ran into this with a more complicated program I have been working on, so I tried just running the example give from SFML to try and isolate the issue and that breaks the exact same way, so it seems to be something to do with SFML, but I don't understand what or why.

This is the code:

#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;
}

This is the call stack:

#0 691C4AF9 sf::VideoMode::VideoMode(unsigned int, unsigned int, unsigned int) () (D:\MyDocs\DOCUME~1\C__~1\SFML2~1.0TE\SFML2T~1\bin\Debug\sfml-window-2.dll:??)
#1 00401424 main() (D:\MyDocs\Documents\C++\SFML 2.0 Test\SFML 2 Test\main.cpp:5)

Does anyone have any idea why this is happening or how I can fix it?

Was it helpful?

Solution

SFML is a C++ library, thus every time you switch the compiler, you need to recompile the library. The pre-compiled binaries provided by SFML are for the older version of TDM and thus not compatible with TDM 4.8.1. Building libraries yourself will become more important the longer you develop, so the sooner you start the better, plus it's not that hard.

As a personal side note: While I appreciate the hard work by TDragon, it's quite a no-go that the TDM compilers change the default linking behavior of GCC, thus breaking about every build script in existance, unless it's specially modified for TDM. Unfortunately the Code::Blocks community doesn't care at all. Thus I feel the need to point people to MinGW Builds whenever possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top