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

Author Topic: New to SFML, getting Access Violation with tutorial code  (Read 1664 times)

0 Members and 1 Guest are viewing this topic.

Kazuar

  • Newbie
  • *
  • Posts: 3
    • View Profile
New to SFML, getting Access Violation with tutorial code
« on: March 08, 2011, 08:53:59 pm »
Hello everybody,

first, I want to excuse for my bad english, it's foreign to me. I am also a novice hobby programmer.

Now, I've installed and tried SFML on my notebook - everything works fine!

However, the same code, as well as the code provided with the "Using render windows" tutorial, crashes on execution on my "main rig". My "own" code is also close to the tutorials code, with just an shape added for playing around (code follows).

I am well aware that this is probably a maschine specific problem, however, I have no idea how.

I'm using VS2008 SP1, and I have compiled SFML separatly on both maschines with the same settings. Both maschines use Win XP SP3. In my project, I link against the static libraries:
Code: [Select]

sfml-graphics-s-d.lib
sfml-window-s-d.lib
sfml-system-s-d.lib
sfml-main-d.lib


Im creating a debug version, of course. I am also providing the IDE with the libs created by the rebuild.

Now, my source code:
Code: [Select]
#include <SFML/Graphics.hpp>

int main(int argc, char** argv)
{
sf::RenderWindow Window( sf::VideoMode(800, 600), "My SFML Test");

//I commented the shape out again, trying to pin the problem down

//sf::Shape Polygon;

//Polygon.AddPoint(0,100, sf::Color(255,255,255), sf::Color(128,128,128) );
//Polygon.AddPoint(50,0,  sf::Color(255,255,255), sf::Color(128,128,128) );
//Polygon.AddPoint(-50,0, sf::Color(255,255,255), sf::Color(128,128,128) );

//Window.SetView( sf::View(sf::FloatRect(-500, -500, 500, 500) ) );

while( Window.IsOpened() )
{
sf::Event Event;
while( Window.GetEvent( Event ) )
{
if( Event.Type == sf::Event::Closed )
Window.Close();
}

Window.Clear();

//Window.Draw(Polygon);

Window.Display();

}

return 0;
}

Again, everything runs fine on my notebook - including the "shape parts".

Starting a debug session from IDE gives me following error message (from VS2008, translated as good as possible):
Quote

Unhandled exception at 0x00000008 in SFML_Test.exe: 0xC0000005: Access violation reading at position 0x00000008.


Thanks to the wonders of "step-by-step" execution, I have found the crashes happens at "Window.Clear()"

Commenting the line out, but leaving the "shape parts" in leads to a similiar error message on "Window.Draw(Polygon)".

Commenting both out gives me a working window (with the expectable garbage showing), but gives me another error message once it hits "return 0":
Quote
Run-Time Check Failure #2 - Stack around the variable 'Window' was corrupted.


The same behaviour can be observed with just the downloaded, mentioned tutorial, as well as an app using sf::Window instead of RenderWindow.

I already looked into the other thread "SFML Crash on App.Clear() and App.Display()", but none of the hints provided there have worked for me so far.

I have installed the newest video drivers, reinstalled my IDE, and completly rebuild SFML, and now I have reached the end of my (admittedly meager) knowledge.

If any of you folks here could provide me with help, I'd be very thankful.

Great thanks in advance!

Kazuar

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New to SFML, getting Access Violation with tutorial code
« Reply #1 on: March 08, 2011, 09:01:37 pm »
And what if you don't recompile SFML?
Laurent Gomila - SFML developer

Kazuar

  • Newbie
  • *
  • Posts: 3
    • View Profile
New to SFML, getting Access Violation with tutorial code
« Reply #2 on: March 08, 2011, 10:57:09 pm »
Thanks for the quick reply, Laurent.

I can't believe I couldn't think of this myself.

So, I downloaded SFML 1.6 for VS2008 again, changed my settings to use the libs from download, and manually removed every trace in my project folder that I tried to build my project before.

Still the same thing, though :(

Edit: Just found out that, if I use the dynamic libs (according to tutorial), everything works perfectly!! So the problem is somehow connected to the *-s.lib's...
I'm still curious as to why my pc "chokes" on the static SFML. I could understand it if it were just my rebuilt libs being somehow corrupted.

But since I have a working workaround now, I can understand if this issue is considered "fixed" ;).
From a learning perspective, though, I would still like to know what is going on. If someone might enlighten me, It'd be very appreciated.

Thanks again for the quick reply, Laurent.

Kazuar

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
New to SFML, getting Access Violation with tutorial code
« Reply #3 on: March 09, 2011, 07:57:28 am »
Maybe something in your VC++ project settings that is not compatible with the build settings of SFML, I don't know. Did you change anything in your project, or did you keep the default settings?
Laurent Gomila - SFML developer

Kazuar

  • Newbie
  • *
  • Posts: 3
    • View Profile
New to SFML, getting Access Violation with tutorial code
« Reply #4 on: March 09, 2011, 12:00:20 pm »
My project kept the default settings (save from the additional dependancies) made by VS. I created an Win32-Project->Empty Project, for that matter.

It should be noted that the project was created on my notebook, and was transferred via flash drive onto my desktop-pc.
Of course, I tested if the problem persists with projects created and built entirely on my main pc, and it does.

 

anything