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

Author Topic: Access Violation when initializing a Render Window on a specific machine  (Read 4780 times)

0 Members and 1 Guest are viewing this topic.

mn12sc35th

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
I'm getting the follow error when trying to initialize a RenderWindow on a specific machine: Unhandled exception at 0x58f5b60e in SFML test.exe: 0xC0000005: Access violation reading location 0x0000002c.

The code that threw that error was simply (created a new project to test):

#include "stdafx.h"
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"


int _tmain(int argc, _TCHAR* argv[])
{
   sf::RenderWindow window;
   return 0;
}


Have had this happen with multiple projects, which build and run fine on my main PC. I've set my project exactly the same as my other PC (even copied the entire project folder over and still gets this). Is there something I'm missing, or could this be a hardware thing?

I was not able to find a similar situation via search thus far...

System that will run this is a Dell T7400 running Windows 7 Ultimate (Dual Xeon X5482 nVidia GTX 660 gfx).
System that will not run this is a Surface Pro running Windows 8 (i5-3317u HD4000 gfx).

Any input on this would be appreciated. Thanks!

EDIT: Corrected the status of this. Project will compile, the error comes when trying to run it.
« Last Edit: May 24, 2013, 02:48:32 am by mn12sc35th »

vipar

  • Newbie
  • *
  • Posts: 23
    • View Profile
Oh man I had this issue like yesterday...how the crap did I solve it.

Try run it as administrator...I think.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
You should always create an empty project and start from there, so you wouldn't get the whole stdafx.h stuff and you can use a normal int main() function.

Besides that you should add SFML to the project settings and then use #include <SFML/MODULE.hpp> to include it and not "". ;)

I highly recommend you read the official tutorial on how to setup your IDE.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

mn12sc35th

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Appreciate the reply. I've read and re-read the setup tutorial, but just to be sure, I went through it again, and matched those settings to mine. Same result. I would think if that was off, it wouldn't even compile (it does just fine).

The "" vs <> include was an oversight on my part (I was in a hurry with that test); the original project that I noticed this in does use  <>. I've also used the precompiled headers (stdafx.h) with SFML (1.6 and 2.0) in the past without this issue. Just to be sure,  I wrote another test without them that returns the same result.

Unhandled exception at 0x58f5b60e in Test2.exe: 0xC0000005: Access violation reading location 0x0000002c.

#include <SFML/Graphics.hpp>

int main(){
   sf::RenderWindow window;
   return 0;
}

Debugger always points to the RenderWindow initialization.

mn12sc35th

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
I tried to run the executable as admin as well. Same result.

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
Make sure you are matching the correct libraries. Only use VS 2008 compiled libraries for VS 2008, VS 2010 libraries for VS 2010... and so on. Also make sure that when your building in debug mode your linking to the sfml-xxx-d.lib files and in release to the sfml-xxx.lib files.

Also when you pass executables to another computer make sure they are not debug builds.
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

mn12sc35th

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
I made sure I had the correct libs (I used the wrong ones once; makes a much more annoying mess). I'm pretty sure I have the correct SFML files, but I'm going to grab a fresh copy of SFML VS2010 just to be sure.

mn12sc35th

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Fresh copy of SFML 32-bit, VS2010. Same error, different address. Same code as the last test.

Unhandled exception at 0x5c19b60e in Test2.exe: 0xC0000005: Access violation reading location 0x0000002c.

What else can I check?

zsbzsb

  • Hero Member
  • *****
  • Posts: 1409
  • Active Maintainer of CSFML/SFML.NET
    • View Profile
    • My little corner...
    • Email
You say it won't run on a Surface Pro that's windows 8. Do you have another machine to test it on such as another windows 7 or maybe vista/xp?

What else can I check?

If you are linking/building it correctly then something is up. What happens if you compile a normal console application (that does not link to SFML) and send that over to your Surface Pro to see if that runs? Other than that check if VS 2010 C++ runtime is installed on your Surface Pro.
« Last Edit: May 24, 2013, 05:13:04 am by zsbzsb »
Motion / MotionNET - Complete video / audio playback for SFML / SFML.NET

NetEXT - An SFML.NET Extension Library based on Thor

mn12sc35th

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
Just to be sure I'm not missing anything in config, there should only be 3 changes (add SFML\include to Additional Include Directories under C++, Add SFML\lib to Additional Library Directories, and add sfml-main/system/window/graphics/network/audio-d.lib to Additional Dependencies under Linker) correct? I'm linking dynamically. I tried this in Release mode (with the non -d .libs linked) and got the same thing as well.

I do have 2010 C++ runtimes (x86 and x64) on it. Everything that I cannot run on this machine will run on my home tower (Win 7 based), but I have been rebuilding each project before trying to run it on both machines.

I've been compiling/running console and Win 32 based apps for my coursework (I'm currently in some C++ programming courses) without issue on this tablet for a few months now.

I just moved that test app over to my tower and ran it straight from the debug folder without issue.

 

anything