Hello everyone!
I've just started learning SFML.
I'm using VirtualBox (4.3.6) and Windows 7 (32 bit) as guest OS, Visual Studio 2010. SFML 2.2.
I follow instuctions in manual http://www.sfml-dev.org/tutorials/2.2/start-vc.php (http://www.sfml-dev.org/tutorials/2.2/start-vc.php) .
Everything works fine except
window.draw(shape);
It causes to error "Unhandled exception at 0x00000000 in Lab7.exe: 0xC0000005: Access violation reading location 0x00000000".
Call stack
00000000()
sfml-graphics-d-2.dll!6ed176a2()
[Frames below may be incorrect and/or missing, no symbols loaded for sfml-graphics-d-2.dll]
sfml-graphics-d-2.dll!6ed172f2()
sfml-graphics-d-2.dll!6ed16a96()
sfml-graphics-d-2.dll!6ed3bb09()
sfml-graphics-d-2.dll!6ed16a13()
sfml-graphics-d-2.dll!6ed399c6()
sfml-graphics-d-2.dll!6ed16a13()
> Lab7.exe!main() Line 33 + 0x1b bytes C++
Lab7.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C
Lab7.exe!mainCRTStartup() Line 371 C
kernel32.dll!758d1194()
ntdll.dll!7748b459()
ntdll.dll!7748b42c()
Without this line of code everything works fine and I see window. I can change its position and color. But I cannot draw something on it. Even for example text:
// Declare and load a font
sf::Font font;
if (!font.loadFromFile("C:\\Windows\\Fonts\\Arial.ttf"))
{
printf("Failed!");
return EXIT_FAILURE;
}
// Create a text
sf::Text text("hello", font);
text.setCharacterSize(30);
text.setStyle(sf::Text::Bold);
text.setColor(sf::Color::Red);
// ...
window.draw(text);
Do you also run it in debug mode?
Provide a complete, compilable and minimal example code.
Thanks for your answer!
I run it in debug mode (with sfml-graphics-d.lib and others) and release modes (with sfml-graphics.lib etc.).
I put neccessary dlls to Debug / Release folders respectively.
I've just started learning SFML.
Minimal compilable code
#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();
// next line of code (draw) crashes application
//window.draw(shape);
window.display();
}
return 0;
}
Verbose build command:
------ Build started: Project: Lab7, Configuration: Debug Win32 ------
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 16.00.30319.01 for 80x86
Copyright (C) Microsoft Corporation. All rights reserved.
cl /c /I"C:\Temp\SFML-2.2\include" /ZI /nologo- /W3 /WX- /Od /Oy- /D SFML_DYNAMIC /D _MBCS /Gm /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Fo"Debug\\" /Fd"Debug\vc100.pdb" /Gd /TP /analyze- /errorReport:prompt main.cpp
cl : Command line warning D9035: option 'nologo-' has been deprecated and will be removed in a future release
Skipping... (no relevant changes detected)
main.cpp
Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation. All rights reserved.
"/OUT:C:\Users\profport32\documents\visual studio 2010\Projects\Lab7\Debug\Lab7.exe" "/LIBPATH:C:\Temp\SFML-2.2\lib" "sfml-graphics-d.lib" "sfml-window-d.lib" "sfml-system-d.lib" "sfml-audio-d.lib" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /MANIFEST "/ManifestFile:Debug\Lab7.exe.intermediate.manifest" "/MANIFESTUAC:level='asInvoker' uiAccess='false'" /DEBUG "/PDB:C:\Users\profport32\documents\visual studio 2010\Projects\Lab7\Debug\Lab7.pdb" /TLBID:1 /DYNAMICBASE /NXCOMPAT "/IMPLIB:C:\Users\profport32\documents\visual studio 2010\Projects\Lab7\Debug\Lab7.lib" /MACHINE:X86 Debug\main.obj
LINK : C:\Users\profport32\documents\visual studio 2010\Projects\Lab7\Debug\Lab7.exe not found or not built by the last incremental link; performing full link
Lab7.vcxproj -> C:\Users\profport32\documents\visual studio 2010\Projects\Lab7\Debug\Lab7.exe
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========