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

Author Topic: Access violation in my first application from tutorial (Win7, VirtualBox)  (Read 4628 times)

0 Members and 1 Guest are viewing this topic.

galyamov.artur

  • Newbie
  • *
  • Posts: 5
    • View Profile
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 .

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
(click to show/hide)

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:
(click to show/hide)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #1 on: February 10, 2015, 01:56:59 pm »
Do you also run it in debug mode?

Provide a complete, compilable and minimal example code.
And give us the verbose build command.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #2 on: February 10, 2015, 01:59:18 pm »
A wild guess in the dark: does your virtual machine have 3D (OpenGl) acceleration enabled and working?

galyamov.artur

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #3 on: February 10, 2015, 06:26:40 pm »
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:
Code: [Select]
------ 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 ==========

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #4 on: February 10, 2015, 06:31:16 pm »
Doesn't matter for your issue, but SFML_DYNAMIC doesn't exist anymore.

I've never used Windows 7 in a VM as such, I'm not sure what possible issues can occur, but as Jesper Juhl said, it's more likely to be an issue with the VM. Is graphics acceleration activated?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

galyamov.artur

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #5 on: February 10, 2015, 06:32:18 pm »
A wild guess in the dark: does your virtual machine have 3D (OpenGl) acceleration enabled and working?

Hm, I don't think about it. Let's see...

galyamov.artur

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #6 on: February 10, 2015, 06:44:10 pm »
Doesn't matter for your issue, but SFML_DYNAMIC doesn't exist anymore.

I've never used Windows 7 in a VM as such, I'm not sure what possible issues can occur, but as Jesper Juhl said, it's more likely to be an issue with the VM. Is graphics acceleration activated?

Yes, that's the answer!
I've activated 3D acceleration and it works! But strange a little.
I'll try 2D acceleration now too.

galyamov.artur

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #7 on: February 10, 2015, 06:51:30 pm »
The result of compilance is here

Also it's a OpenGL warning in console: DrvShareLists: unsupported.

Maybe some troubles with drivers support in VirtualBox.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Access violation in my first application from tutorial (Win7, VirtualBox)
« Reply #8 on: February 17, 2015, 07:27:25 pm »
Make sure you have the 'virtualbox guest additions' installed inside the VM. Otherwise performance will suck (even more than it usually does in a VM) and some features will not be available at all.

 

anything