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

Author Topic: [Win32/VS2005] Crash in Release Mode  (Read 3332 times)

0 Members and 1 Guest are viewing this topic.

MadMartin

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
[Win32/VS2005] Crash in Release Mode
« on: July 30, 2008, 02:35:58 pm »
Hi everybody,

today I started to make a skeleton for any applications I'm going to create. It's a very simple Application class:

Header:
Code: [Select]

#ifndef H_APPLICATION
#define H_APPLICATION

#include <SFML/Graphics.hpp>

class Application {

public:
int Run();

private:
bool InitApp();
sf::RenderWindow MainWindow;
};
#endif


Implementation:
Code: [Select]

#include "Application.h"

int Application::Run(){
if (!InitApp()){
return -1;
}

while (MainWindow.IsOpened()){
        // Process events
        sf::Event Event;
        while (MainWindow.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                MainWindow.Close();
        }

        // Display window contents on screen
        MainWindow.Display();
}

return 0;
};

bool Application::InitApp() {
MainWindow.Create(sf::VideoMode(640, 480), "TheEye");

return true;
};


main.cpp
Code: [Select]

#include "Application.h"

int main() {
Application TheApp;
return TheApp.Run();
}


As you see, I'd like to seperate initialisation, event handling etc in seperate methods of my class Application. Straight OOP.

My Problem now is a exception that occurs just after closing the window in Release mode.

Error message is
Quote
A buffer overrun has occurred in TheEye.exe which has corrupted the program's internal state. Press Break to debug the program or Continue to terminate the program.

The program breaks at line 298 in the file gs_report.c from Microsoft.

Any ideas how to solve this? CRT is dynamically linked, Unicode enabled, I'm using sfml-main-d.lib, sfml-window-d.lib and sfml-graphics-d.lib in Debug mode and sfml-main.lib, sfml-window.lib and sfml-graphics.lib in Release mode.

greetings
Martin

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
[Win32/VS2005] Crash in Release Mode
« Reply #1 on: July 30, 2008, 02:47:49 pm »
Did you try disabling Unicode ?
Did you try dynamic / static SFML libraries ?
You don't mix release and debug libraries ?
Laurent Gomila - SFML developer

MadMartin

  • Jr. Member
  • **
  • Posts: 74
    • View Profile
[Win32/VS2005] Crash in Release Mode
« Reply #2 on: July 30, 2008, 02:55:23 pm »
Ok, tried out you suggestions:

- Unicode makes no difference
- no mix up in libraries

Then I switched to static linking, had to add sfml-system.lib and now it works without errors. But it won't work with dynamic linking though.

That is not bad, I don't care if I need to deploy the DLLs and I don't care about the file size. Nonetheless I'm curious what's the problem at this very point.

By the way: Should I link to the CRT statically or dynamically when using SFML? Or link the same way I did to SFML? Or does it make no difference whether I use dynamic or static linking?

 

anything