Using SFML with Visual Studio 2010

Moridin

Snow Leopard
Reaction score
144
Hey there,

Right now I'm trying to get SFML to work with my Visual Studio 2010, so I can start learning how to make windows applications and games using the libraries within SFML. I'm following the tutorial here to open a new window, but my program seems to break instantly. I really don't know why :S. It seems to build and compile, but then breaks.

Edit: It breaks at this line:
App.Create(sf::VideoMode(800, 600, 32), "SFML Window");

Edit: This is the output I get:
'SFML Tutorials.exe': Loaded 'C:\Users\100464441\Documents\Visual Studio 2010\Projects\SFML Tutorials\Debug\SFML Tutorials.exe', Symbols loaded.
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\KernelBase.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Users\100464441\Documents\Visual Studio 2010\Projects\SFML Tutorials\Debug\sfml-window-d.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\opengl32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\sechost.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\lpk.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\usp10.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\glu32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\ddraw.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\dciman32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\setupapi.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\cfgmgr32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\devobj.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Users\100464441\Documents\Visual Studio 2010\Projects\SFML Tutorials\Debug\sfml-system-d.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcp90d.dll', Symbols loaded.
'SFML Tutorials.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_2a4f639a55563668\msvcr90d.dll', Symbols loaded.
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\msvcp100d.dll', Symbols loaded.
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\msvcr100d.dll', Symbols loaded.
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\imm32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\msctf.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\nvinit.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\detoured.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\Nvd3d9wrap.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Program Files\NVIDIA Corporation\coprocmanager\nvdxgiwrap.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\uxtheme.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Program Files\RocketDock\RocketDock.dll', Binary was not built with debug information.
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\psapi.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\wintrust.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\crypt32.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\msasn1.dll', Cannot find or open the PDB file
'SFML Tutorials.exe': Loaded 'C:\Windows\System32\nvoglv32.dll', Cannot find or open the PDB file
The thread 'Win32 Thread' (0x8c0) has exited with code 0 (0x0).
First-chance exception at 0x75698210 in SFML Tutorials.exe: 0xC0000005: Access violation reading location 0x6e695720.
Unhandled exception at 0x75698210 in SFML Tutorials.exe: 0xC0000005: Access violation reading location 0x6e695720.

Code:
#include <SFML/Window.hpp>

int main ()
{
	sf::Window App;
	App.Create(sf::VideoMode(800, 600, 32), "SFML Window");
	bool Running = true;
	while (Running)
	{
		sf::Event Event;
		while (App.GetEvent(Event))
		{
			if (Event.Type == sf::Event::Closed)
				Running = false;
			
			if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Escape))
				Running = false;

		}
		App.Display();
	}

	return EXIT_SUCCESS;
}

Also, I should note:
On the SFML website, the tutorials for setting it up with Visual Studio seem to be for VS 2008 (Setting up SFML with VS). I managed to get a set of instructions for VS2010 and set it up. I used a short program to test if the SFML libraries were working:

Code:
#include <SFML/System.hpp>
#include <iostream>

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

    return 0;
}

^This program worked fine.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Hm. Works fine for me.
Have you made sure that all DLLs are available?

Try to step through your program using a Breakpoint. See what line it breaks at.
 

Moridin

Snow Leopard
Reaction score
144
s3rius said:
Try to step through your program using a Breakpoint. See what line it breaks at.
Ah, I forgot to mention. It breaks at this line:

App.Create(sf::VideoMode(800, 600, 32), "SFML Window");

I'll edit the original post now.

Edit: I also do realise that my setup of SFML might be the problem, which is why I elaborated on my difficulties with setting it up. However, the second program I displayed seems to work, is there anything specific I can check?

Edit2: As for the DLLs you mentioned, I copied all the DLLs to the Debug folder with the .exe file. Would this be the correct place to put them?
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Yes, that's the correct place.

It probably has something to do with your library setup. Since it works for me with the exact same code.

Make sure that you've included all the .lib files inside your project setup. Especially the SFML-Window-d.lib (or whatever it's name was).
 

Moridin

Snow Leopard
Reaction score
144
Hmm, I went to my project properties and I realised that I wasn't including all the s lib files (sfml-window-s-d.lib, sfml-system-s-d.lib, etc). Included them now, but it seems to make no difference.

If you remember, could you detail the list of things you did to setup SFML with your VS 2010? I really can't seem to find a fault with my setup :S, at least according to the tutorial given here.
 

camelCase

The Case of the Mysterious Camel.
Reaction score
362
I'm not sure if version 1.6 is compatible is VS2010 =/
I know that 2.0 should be.
 

Moridin

Snow Leopard
Reaction score
144
I'm not sure if version 1.6 is compatible is VS2010 =/
I know that 2.0 should be.

I checked this out, and you might be right. However, over here, it shows someone having the exact same problem I have, and yet getting it solved simply by including the library files in the linker list...so yet again, I'm not sure. I think I might try SFML 2.0.

Also, I edited the OP with the error output for convenience.

*Note: could someone tell me how to use spoiler tags? I can't seem to get it right.
 

UndeadDragon

Super Moderator
Reaction score
447
*Note: could someone tell me how to use spoiler tags? I can't seem to get it right.

[noparse]
Your text goes here.
[/noparse]
 

UndeadDragon

Super Moderator
Reaction score
447
Ah. Thank you for that. It doesn't seem to work on this forum though.

You're right, they appear to be disabled on this forum :p
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
I'm using VS2010 and SFML1.6, so that's alright.

My project settings are these:

Linker -> Input -> Additional Dependencies:
sfml-audio-d.lib
sfml-graphics-d.lib
sfml-window-d.lib
sfml-system-d.lib
sfml-main-d.lib
sfml-network-d.lib

C/C++ -> Preprocessor -> Preprocessor Definitions:
SFML_DYNAMIC

The preprocessor definition is important. And you usually don't have to use the sfml-xxx-s-d.lib stuff, but the ones without the -s, If I remember correctly.
 

Moridin

Snow Leopard
Reaction score
144
hmm, I just realised I didn't do the preprocessor definition. Fixed that now.

Same error as before though. The program builds, compiles, runs and then immediately breaks. Ha le sigh, this is getting annoying :/.
I'm pretty sure my linked libraries are fine, otherwise it wouldn't even build. It would instead give me a linker error, but that's not what it's doing.

Along with that, even though I've double and triple checked that the dlls exist in the directory, it says this:
'SFML Tutorials.exe': Loaded 'C:\Users\100464441\Documents\Visual Studio 2010\Projects\SFML Tutorials\Debug\sfml-window-d.dll', Cannot find or open the PDB file

Along with that, when I DO remove the dll file from that directory, upon building it gives me an execution error saying that the dlls are missing.
So when the DLL is there, it doesn't do that.

I really don't get this :S.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
I'm pretty much out of ideas too.

But if you can zip your project folder and upload it/send it to me I could take a closer look on the setup.
 

Moridin

Snow Leopard
Reaction score
144
Alright. I've uploaded the entire project:

http://www.mediafire.com/file/bc41gjly6m9vou5/Project.zip

It's 20mb, so I couldn't upload it on the helper. I hope you don't mind downloading from mediafire. If you have a preferred uploader due to security reasons, I won't mind using it. Also, I know, the project's name is 'Project'. I just couldn't think of an original name at the time xd.

Thanks for taking the time to look into this.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Nah, mediafire is my prefered webhoster too.

Ok, so the problem lies in your DLLs. They're probably badly compiled, or compiled for some other version or something. No idea really.

Using my own DLL version it runs no prob:


View attachment DLLS.rar
 

Moridin

Snow Leopard
Reaction score
144
Oh awesome. I tried it out and it works just fine. I was wondering why nothing worked lol.

Thank you very much for your help. I can start to learn SFML now. Gotta make games :D.
 

Moridin

Snow Leopard
Reaction score
144
Alright, I'm now trying to do the tutorial for basic OpenGL. Didn't want to start a new thread, because my problem might be the same thing over again.

I'm getting a linker error:
1>C:\Users\100464441\Documents\Visual Studio 2010\Projects\Project\Debug\Project.exe : fatal error LNK1120: 14 unresolved externals

...with a bunch of unresolved external symbols to do with openGL:
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glEnd@0 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glVertex3f@12 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glBegin@4 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glRotatef@16 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glTranslatef@12 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glClear@4 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glViewport@16 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol _gluPerspective@32 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glLoadIdentity@0 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glMatrixMode@4 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glDepthMask@4 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glEnable@4 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glClearColor@16 referenced in function _main
1>OpenGL.obj : error LNK2019: unresolved external symbol __imp__glClearDepth@8 referenced in function _main

So, here are the libraries I currently have linked in:
sfml-audio-d.lib;
sfml-graphics-d.lib;
sfml-main-d.lib;
sfml-network-d.lib;
sfml-system-d.lib;
sfml-window-d.lib;

I also SFML_DYNAMIC added to the preprocessor defintions.
If all that is how it's supposed to be and I haven't missed anything, then could I possibly have your set of .lib files as well?

Thanks again.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
If you want to use OpenGL you'll have to download their DLLs and include them too.
I can't help you much with setting it up since I haven't used OpenGL myself yet.

But I'd stick to solely SFML for the time being.

The tutorials on the SFML-homepage are a bit misleading in that respect. You don't need OpenGL to work with SFML. It's just an addition, so you don't even need that tutorial.

You can also skip some other tutorials:
Integrating to a Win32 interface
Integrating to a X11 interface
Integrating to a Qt interface
Integrating to a wxWidgets interface
 

Moridin

Snow Leopard
Reaction score
144
Oh alright. That makes sense. I'm wondering then, what would be the easiest way to draw things / use layers /etc with SFML and VS 2010? Are there a set of functions / commands that do this natively?

Edit: Alright, I've looked at the next set of tutorials to do with the SFML graphics package. I was wondering if you had any samples of code I might look at. I need really simple things tbh, basic drawing, loading sprites from files, etc.
 

s3rius

Linux is only free if your time is worthless.
Reaction score
130
Isn't this a good example?
http://www.sfml-dev.org/tutorials/1.6/graphics-sprite.php

There's working source code too.

I don't really have code samples of basic things. All the sfml stuff I have is more advanced.
I can help with more specific problems though - or to improve working code (e.g. a resource cache is something that's not explained in the sfml tutorials but is pretty much necessary later).
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top