Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Run-Time Check Failure VS 2013  (Read 1284 times)

0 Members and 1 Guest are viewing this topic.

coldscrip

  • Newbie
  • *
  • Posts: 5
    • View Profile
Run-Time Check Failure VS 2013
« on: July 18, 2014, 08:17:58 am »
Project only contains main.cpp

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

I get the following error:

Run-Time Check Failure #2 - Stack around the variable 'window' was corrupted.

A buffer overrun has occurred in SFMLTutorial2.exe which has corrupted the program's internal state.

...whenever I close the window with the example circle being drawn. This only occurs with a debug build, not a release build.

I am using Visual Studio 2013 which means I have to remake the SFML binaries. No problem I download the latest here: https://github.com/SFML/SFML/archive/master.zip

I made static libraries in cmake. One thing I noticed is that the project still requires opengl32.lib and winmm.lib which was not made by cmake. I assume these already exist with the platform/compiler.

Linker->Input->Additional Dependencies:
freetype.lib
glew.lib
jpeg.lib
openal32.lib
sndfile.lib
opengl32.lib
winmm.lib
gdi32.lib
sfml-main-d.lib
sfml-audio-s-d.lib
sfml-network-s-d.lib
sfml-graphics-s-d.lib
sfml-window-s-d.lib
sfml-system-s-d.lib

C/C++->Preprocessor->Preprocessor Definitions:
WIN32
_DEBUG
_WINDOWS
SFML_STATIC

Any thoughts? In my research it seems that others who have had this problem mix linking debug/release libs. As far as I can tell I have not. Any help would be greatly appreciated.
« Last Edit: July 18, 2014, 08:22:24 am by coldscrip »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Run-Time Check Failure VS 2013
« Reply #1 on: July 18, 2014, 08:28:44 am »
Double-check your settings, this always happens when you link incompatible libraries (mixing Debug/Release, or different compiler versions). Have you recompiled SFML with the same compiler settings that your application uses? Isn't there a leftover SFML version that your application might link instead?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

coldscrip

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Run-Time Check Failure VS 2013
« Reply #2 on: July 18, 2014, 03:18:43 pm »
Nexus,

Your comment was all it took! Well that and a few hours of sleep. Right after reading your response it clicked. In C/C++->General->Additional Include Directories I was still referencing the old include directory, not the one that I had compiled. I redirected it to the include directory that I compiled and it worked beautifully. Thank you!