SFML community forums

Help => Window => Topic started by: lotios611 on December 05, 2009, 04:00:06 pm

Title: [SOLVED] Window Crashing
Post by: lotios611 on December 05, 2009, 04:00:06 pm
Hello, I am trying to run the code on the tutorials about events using a window. I have the linker set up, but it still doesn't work. The most annoying thing is that I can get the System to work, but not Window.
Title: [SOLVED] Window Crashing
Post by: Nexus on December 05, 2009, 04:27:01 pm
Can you express yourself a little bit more precisely? What doesn't work?

A short example with related error messages wouldn't be bad.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 05, 2009, 04:38:59 pm
The program compiles, but when I go to run it, it says "Learning SFML has encountered a problem and needs to close." Here's the code:

Code: [Select]
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Window.hpp>

////////////////////////////////////////////////////////////
/// Entry point of application
///
/// \return Application exit code
///
////////////////////////////////////////////////////////////
int main(int argc, char **argv)
{
// Create the main window
sf::Window App(sf::VideoMode(800, 600), "SFML Events");

// Start main loop
while (App.IsOpened())
{
// Process events
sf::Event Event;
while (App.GetEvent(Event))
{
// Close window : exit
if (Event.Type == sf::Event::Closed)
App.Close();

                // Escape key : exit
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
App.Close();
}
// Display window on screen
App.Display();
}

return EXIT_SUCCESS;
}

I know that the error happens when I create a window.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 05, 2009, 05:21:56 pm
Do you link to the debug libraries in debug mode?
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 05, 2009, 11:07:21 pm
Yes.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 05, 2009, 11:38:52 pm
You should use the debugger to have more informations about the crash.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 06, 2009, 12:11:58 am
I know that it happens when I create the window.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 06, 2009, 12:17:12 am
This is all I can get: Unhandled exception at 0x7c809e32 in SFML Programming.exe: 0xC0000005: Access violation reading location 0x65764520.

I created a new project, but it's the exact same as before.
Title: [SOLVED] Window Crashing
Post by: Tank on December 06, 2009, 03:35:01 am
Are you sure you're linking to sfml*-d.lib in your debug configuration? Maybe upload a minimal example together with project files.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 06, 2009, 11:04:50 am
You should really learn to use the debugger.

What IDE do you use? Visual Studio? Code::Blocks?
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 06, 2009, 02:34:06 pm
I use Visual Studio.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 06, 2009, 02:40:22 pm
So you just have to run your application using F5 to enable the debugger ;)
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 07, 2009, 12:37:25 am
I added #define SFML_DYNAMIC, but it still doesn't work. Is that the correct way to do it?
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 07, 2009, 01:01:59 am
Great. Now it says something about a buffer overrun.
Title: [SOLVED] Window Crashing
Post by: TickingHands on December 07, 2009, 03:15:52 am
I had something like that...

Except my problem was that I had both the normal .lib and the -d.lib linked. Make sure that isn't the problem either.

Hope you fix the problem.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 07, 2009, 07:37:31 am
Quote from: "lotios611"
Great. Now it says something about a buffer overrun.

It really looks like you're using the release libraries in debug mode.
Title: [SOLVED] Window Crashing
Post by: K-Bal on December 07, 2009, 11:59:05 am
Just list the names of the libraries you are using.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 07, 2009, 12:26:27 pm
I'm using sfml-system.lib and sfml-window.lib and am compiling in Release.
Title: [SOLVED] Window Crashing
Post by: K-Bal on December 07, 2009, 12:27:37 pm
You also need sfml-main when using MSVC.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 07, 2009, 12:30:52 pm
It still doesn't work.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 07, 2009, 01:32:37 pm
Can you upload your whole project with sources?
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 08, 2009, 12:11:06 pm
http://rapidshare.com/files/317951451/SFML_Programming.vcxproj.html I think that should work... I've never used rapidshare before.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 08, 2009, 01:10:33 pm
Quote
 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
      <AdditionalDependencies>sfml-window.lib;sfml-system.lib;%(AdditionalDependencies)</AdditionalDependencies>
  </ItemDefinitionGroup>

Your debug configuration is wrong... Should be sfml-window-d and sfml-system-d.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 08, 2009, 09:48:02 pm
I thought I was compiling in Release mode. Anyways, It still doesn't work.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 08, 2009, 09:54:49 pm
The worst thing about it is that I can use the System class but not the Window class.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 08, 2009, 10:17:58 pm
Quote
I thought I was compiling in Release mode

I don't know what configuration you compile, but anyway the debug one is wrong ;)
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 09, 2009, 12:41:59 am
Okay, I've just tried debugging again. My Window's name is app. Inside it, it has a thing called myInput. In that, there's a sf::Window. Inside that, there's something called _vfptr. It's value is NULL. Inside that there are 2 values, and both of them say "CXX0030: Error: expression cannot be evaluated." I'm not to good at debugging, so this is all I can find.
Title: [SOLVED] Window Crashing
Post by: Oz1571 on December 09, 2009, 02:02:52 am
Can't you just zip your whole project up, including source, and upload it somewhere? I could take a look, or I'm sure Laurent would.
Title: [SOLVED] Window Crashing
Post by: Laurent on December 09, 2009, 08:42:11 am
Did you run the debugger in Debug configuration? :D

Quote
I'm sure Laurent would

Absolutely ;)
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 12, 2009, 06:08:47 pm
Here you go: http://rapidshare.com/files/319911453/SFML_Project.zip.html
Title: [SOLVED] Window Crashing
Post by: Adi on December 12, 2009, 06:23:05 pm
Your program crashes because you use Visual Studio 2010, which is still a beta and have errors that makes sfml not working (i don't know why but for example ogre3D also crashes before creating window)

Try downloading Visual C++ Express 2008
Title: [SOLVED] Window Crashing
Post by: Laurent on December 12, 2009, 06:23:23 pm
Can you upload it elsewhere please ? Rapidshare keeps on bothering me...
Title: [SOLVED] Window Crashing
Post by: Oz1571 on December 12, 2009, 09:11:11 pm
If you really are using visual studio 2010 that would probably explain the issues you've been having. Try the 2008 version.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 12, 2009, 10:18:47 pm
Luckily, I still have Visual 2008, will try that.
Title: [SOLVED] Window Crashing
Post by: lotios611 on December 12, 2009, 10:30:25 pm
Quote from: "Adi"
Your program crashes because you use Visual Studio 2010, which is still a beta and have errors that makes sfml not working (i don't know why but for example ogre3D also crashes before creating window)

Try downloading Visual C++ Express 2008


Thanks man! I think I'll go back to 2008. 2010 looks kind of ugly... anyways, can't wait to work with SFML!
Title: [SOLVED] Window Crashing
Post by: K-Bal on December 13, 2009, 01:01:35 am
Quote from: "lotios611"
Quote from: "Adi"
Your program crashes because you use Visual Studio 2010, which is still a beta and have errors that makes sfml not working (i don't know why but for example ogre3D also crashes before creating window)

Try downloading Visual C++ Express 2008


Thanks man! I think I'll go back to 2008. 2010 looks kind of ugly... anyways, can't wait to work with SFML!


I'm glad you solved this issue ;) So go ahead and make great software :D