SFML community forums

Help => Window => Topic started by: Lynx876 on August 28, 2011, 11:43:02 pm

Title: Access Violation.
Post by: Lynx876 on August 28, 2011, 11:43:02 pm
A few things first.

Can SFML run on VS2010? I've noticed that there are not any files for this version.

Can I create a window from SFML to run on a 32" TV? I use this as my monitor via HDMI.
I've noticed a few people having problems with having more than one monitor etc.


So, here's the code that compiles, it's the tutorial code for the window:
Code: [Select]
#include "stdafx.h"

int main()
{
    // Create the main window
    sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window");

    // Start main loop
    bool Running = true;
    while (Running)
    {
        App.Display();
    }

    return EXIT_SUCCESS;
}


This is what gives me the access violation as soon as it opens a console window. The code compiles fine.

In debug, I have these lines within the call stack window:
>   nvoglv32.dll!6980e3c3()    
    [Frames below may be incorrect and/or missing, no symbols loaded for nvoglv32.dll]   
    nvoglv32.dll!69820fdc()    
    nvoglv32.dll!6975eba0()

I've linked everything correctly, that I'm aware of and included the window.hpp within my stdafx.h.

If anyone could shed some light on this, as to why it's not working or something I am doing wrong, I'd be very greatful, thanks.

EDIT: Just some more info.

I'm running Windows 7 x64.
Nvidia GeForce GTX 550 Ti with the latest drivers.
Title: Access Violation.
Post by: Laurent on August 29, 2011, 08:15:49 am
Quote
Can SFML run on VS2010?

No, so you must recompile it ;)
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 01:36:40 pm
Thanks for the reply. I did a lot of reading around last night, managed to build the files, I think... lol.

I've never had to build any files before, but what I got from the tutorial on here and some forum posts, I managed to get these files with CMake.

(http://i749.photobucket.com/albums/xx132/Bigdave876/Websites/cmake-2.jpg)

After using CMake to create these files, I then loaded ALL_BUILD.vcxproj and pressed F7 ( Build ).

I also add the additional dependancies:
Properties > Linker > Input > Additional Dependancies
   sfml-system.lib;sfml-graphics.lib;sfml-window.lib;sfml-audio.lib;sfml-network.lib

From what I'm doing, this should now work correctly?
Do I still need to add the include/lib directories? Now that they are in the VS2010 directoy.

I can still run the clock tutorial from this site, but as soon as I add a line to create a render window, I always get the 0x05 access violation error.

Code: [Select]
int _tmain(int argc, _TCHAR* argv[])
{
//error here
//sf::RenderWindow App( sf::VideoMode( 800, 600, 32 ), "My SFML Window" );

    sf::Clock Clock;

    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);

if( _kbhit() )
break;
    }

    return 0;
}


Sorry if you think I'm dumb, lmao. Been at this ( trying to get it to work ) for too long now.
Title: Access Violation.
Post by: Laurent on August 29, 2011, 02:00:48 pm
Oh, it's SFML 2. I thought you were using SFML 1.6 because you said "there's no file for VC++ 2010" -- SFML 2 is not released so there's no file at all (for any version of any compiler on any OS) ;)

If you compile in debug mode you must link the debug libraries (sfml-system-d.lib etc.).
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 02:24:04 pm
Yeah, I tried to use both of them. I just deleted it all and tried to start again. Is it possible to rebuild the files from the 1.6 so that they work in VS2010?
If so, how? lol.

When I use the vs2008 files, I can compile the clock code from above and it works fine, but that's compiling in debug and using the sfml-system.lib. I always get errors when I link to -d libs.
Title: Access Violation.
Post by: Laurent on August 29, 2011, 02:30:12 pm
Quote
Is it possible to rebuild the files from the 1.6 so that they work in VS2010?

Of course. Open build/vc2008/SFML.sln, convert it using the wizard, and compile it.

But SFML 2 should work fine with VC++ 2010 if you followed the tutorial step by step.
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 02:56:55 pm
ok, I'm sorry for being really dumb here ):

I just deleted everything to do with SFML, yet again, from my download folders and from the VC directories.

I've built all the files etc ( from 2.0 again ), do I need to copy anything from the built files to the VC directories, as when I use '#include <SFML/...>' I don't even have the folder there to pick an .hpp file.

I'm sure last time I did this, it added all the include files into the VC directory for me.

I tried to link the '...lib\Release' where all the build files are, but nothing.

Cheers for trying to help me! lol.
Title: Access Violation.
Post by: Laurent on August 29, 2011, 03:15:00 pm
Quote
I'm sure last time I did this, it added all the include files into the VC directory for me.

Nop. You must tell your compiler where the headers and libs are (it is explained in the SFML 1.6 tutorials).
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 03:20:33 pm
Sorry, I thought I posted back in here a minute ago.

I copied the "...2.0\include\SFML" to my VC directory. I have the clock code running fine again. But as soon as I add the render window line in, it just gives me the 0x05 error ):

Edit
:
Actually, I'm not getting the 0x05 access violation now. It just crashes... lol

Problem signature:
  Problem Event Name:   APPCRASH
  Application Name:   clock.exe
  Application Version:   0.0.0.0
  Application Timestamp:   4e5b9263
  Fault Module Name:   nvoglv32.DLL
Title: Access Violation.
Post by: Laurent on August 29, 2011, 03:28:29 pm
You're still using the -d libraries in debug mode, right? ;)

If you use the dynamic libraries, make sure that your program is using the right .dll files.
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 03:39:44 pm
Any way I try it, I get an access violation.

This is my additional dependancies:
sfml-system-d.lib
sfml-graphics-d.lib
sfml-window-d.lib
Title: Access Violation.
Post by: Laurent on August 29, 2011, 03:52:43 pm
You didn't answer my question (ok, that wasn't exactly a question...) about DLL files.
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 04:21:51 pm
Quote from: "Laurent"
You didn't answer my question (ok, that wasn't exactly a question...) about DLL files.


Oh, yeah. lol. I've tried linking every which way. I just can't figure this out :/
Title: Access Violation.
Post by: Laurent on August 29, 2011, 04:28:27 pm
I'm not talking about linking, I'm talking about which DLL files are used when you launch your executable.
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 04:32:50 pm
Quote from: "Laurent"
I'm not talking about linking, I'm talking about which DLL files are used when you launch your executable.


You mean the one's you copy to the executable folder for runtime? Sorry, everything I've ever written in C++ games/apps, I've never used any other dll's etc.

If you do mean them, I've copied the dll's from the build I did of them "SFML\x86Build\lib\Release" or "SFML\x86Build\lib\Debug"
Title: Access Violation.
Post by: Laurent on August 29, 2011, 05:02:50 pm
Should be ok then.

Try the static libraries (-s), just to be sure.
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 05:20:22 pm
I don't have any -s files anywhere in the build :/

I told CMake to create them, but nothing...
Title: Access Violation.
Post by: Laurent on August 29, 2011, 05:41:47 pm
You must uncheck "BUILD_SHARED_LIBS" to build them. This is explained in the tutorial.
Title: Access Violation.
Post by: Lynx876 on August 29, 2011, 05:45:42 pm
That's the way I've done it each time, I only checked the box when you said about it in your last post.

Edit:
Just tried a static link, nothing, just more errors.

Think I'll give up on it. Have to learn openGL or something. It's got to be easier than this. Thanks a lot for the help.
Title: Access Violation.
Post by: Laurent on August 29, 2011, 05:59:10 pm
If you do things properly and follow the CMake tutorial, things should work out of the box. People having such problems usually mix things they shouldn't (configuration problem) or still have old SFML versions that conflict with the new one.

Quote
That's the way I've done it each time, I only checked the box when you said about it in your last post.

So how could you link to sfml-system-d.lib etc., which are dynamic libraries, if you always built the static libraries so far? Are you sure that the .lib files that you use are the one that you compiled? Those should have a -s suffix, if they are the static version (box unchecked).
Title: Access Violation.
Post by: Lynx876 on September 07, 2011, 11:21:09 pm
Sorry fella, I was so p*ssed off when I was writing those last messages.

I never realised you were the person that wrote this(SFML), but that's not why I'm apologizing.

It turned out that the driver I had installed was corrupt!! I now have SFML working and it's pretty damn good!

I mainly came back to say thanks for trying to help me when I was being a d*ck and thanks for sharing your great work!
Title: Access Violation.
Post by: OniLinkPlus on September 08, 2011, 05:30:44 am
Quote from: "Lynx876"
Sorry fella, I was so p*ssed off when I was writing those last messages.

I never realised you were the person that wrote this(SFML), but that's not why I'm apologizing.

It turned out that the driver I had installed was corrupt!! I now have SFML working and it's pretty damn good!

I mainly came back to say thanks for trying to help me when I was being a d*ck and thanks for sharing your great work!
I can't believe nobody picked up on the fact that it was a driver error, considering what the errors in your OP were.
Title: Access Violation.
Post by: Haikarainen on September 08, 2011, 12:20:02 pm
:D On a latter note, while static linkage is on the issue; You should build SFML and STD libs as static, this way you get rid of ALL neccessary DLL-files, and you know how much we hate DLL's in Windows!

In Linux on the other hand, always build and link shared SFML and STD unless you don't use a very very rare african library that only people with higher power can reach, but if you use linux you probably already know that :P
Title: Access Violation.
Post by: slotdev on September 08, 2011, 02:21:56 pm
By the way, your 32" TV is just another monitor, so open a window to the size of whatever you need. Your TV probably has a max resolution of 1920x1080 or something like that.