Hi, I'm quite new to SFML but decent in C++ and encountered a weird problem I thought I might share with you
I was following
this tutorial, which is written with SFML 1.6. I've made a minimal working example to be found at the bottom.
In 1.6 it works as it should, but when converting to 2.0 I got an Unhandled exception and I have no clue why. All should be setup correctly since I've read the tutorial
Getting Started multiple times to make sure I've made no mistake.
The error is at line 4 when creating a
sf::Renderwindow in the global scope.
Could this be a bug or is it intentional? If it is intentional, can anyone point out why?
Working under Windows 7, in MS Visual C++ 2010 Express. Linked SFML 2.0 statically and the exact error is:
Unhandled exception at 0x777122b2 in TestSFML_2.0.exe: 0xC0000005: Access violation writing location 0x00000004.Here is the minimal working example for 1.6, thus working:
#include <SFML/Graphics.hpp>
// create window in global scope
sf::RenderWindow window;
// MAIN FUNCTION
int main(int argc, char *argv[]) {
window.Create(sf::VideoMode(640,380), "SFML Window"); // initialize window
// wait for close event to close
sf::Event ev;
while(window.IsOpened()) {
while (window.GetEvent(ev)) {
if (ev.Type == sf::Event::Closed)
window.Close();
}
}
return 0;
}
And for the error in 2.0, which throws an exception on line 4
#include <SFML/Graphics.hpp>
// create window in global scope
sf::RenderWindow window;
// MAIN FUNCTION
int main(int argc, char *argv[]) {
window.create(sf::VideoMode(640,380), "SFML Window"); // initialize window
// wait for close event to close
sf::Event ev;
while(window.isOpen()) {
while (window.pollEvent(ev)) {
if (ev.type == sf::Event::Closed)
window.close();
}
}
return 0;
}
Debug window (why are none of these files anywhere on my pc?):
'TestSFML_2.0.exe': Loaded 'C:\Users\Dieter\Documents\Visual Studio 2010\Projects\TestProject\Debug\TestSFML_2.0.exe', Symbols loaded.
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\opengl32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\glu32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\ddraw.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\dciman32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\setupapi.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\cfgmgr32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\devobj.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\winmm.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', Cannot find or open the PDB file
'TestSFML_2.0.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', Cannot find or open the PDB file
First-chance exception at 0x777122b2 in TestSFML_2.0.exe: 0xC0000005: Access violation writing location 0x00000004.
Unhandled exception at 0x777122b2 in TestSFML_2.0.exe: 0xC0000005: Access violation writing location 0x00000004.
The program '[1300] TestSFML_2.0.exe: Native' has exited with code -1073741819 (0xc0000005).