SFML community forums
Help => Window => Topic started 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.
-
Can you express yourself a little bit more precisely? What doesn't work?
A short example with related error messages wouldn't be bad.
-
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:
////////////////////////////////////////////////////////////
// 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.
-
Do you link to the debug libraries in debug mode?
-
Yes.
-
You should use the debugger to have more informations about the crash.
-
I know that it happens when I create the window.
-
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.
-
Are you sure you're linking to sfml*-d.lib in your debug configuration? Maybe upload a minimal example together with project files.
-
You should really learn to use the debugger.
What IDE do you use? Visual Studio? Code::Blocks?
-
I use Visual Studio.
-
So you just have to run your application using F5 to enable the debugger ;)
-
I added #define SFML_DYNAMIC, but it still doesn't work. Is that the correct way to do it?
-
Great. Now it says something about a buffer overrun.
-
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.
-
Great. Now it says something about a buffer overrun.
It really looks like you're using the release libraries in debug mode.
-
Just list the names of the libraries you are using.
-
I'm using sfml-system.lib and sfml-window.lib and am compiling in Release.
-
You also need sfml-main when using MSVC.
-
It still doesn't work.
-
Can you upload your whole project with sources?
-
http://rapidshare.com/files/317951451/SFML_Programming.vcxproj.html I think that should work... I've never used rapidshare before.
-
<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.
-
I thought I was compiling in Release mode. Anyways, It still doesn't work.
-
The worst thing about it is that I can use the System class but not the Window class.
-
I thought I was compiling in Release mode
I don't know what configuration you compile, but anyway the debug one is wrong ;)
-
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.
-
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.
-
Did you run the debugger in Debug configuration? :D
I'm sure Laurent would
Absolutely ;)
-
Here you go: http://rapidshare.com/files/319911453/SFML_Project.zip.html
-
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
-
Can you upload it elsewhere please ? Rapidshare keeps on bothering me...
-
If you really are using visual studio 2010 that would probably explain the issues you've been having. Try the 2008 version.
-
Luckily, I still have Visual 2008, will try that.
-
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!
-
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