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

Author Topic: Can't get VC++ to run with SFML [Solved]  (Read 41769 times)

0 Members and 1 Guest are viewing this topic.

Pikmeir

  • Newbie
  • *
  • Posts: 31
    • View Profile
Can't get VC++ to run with SFML [Solved]
« on: August 02, 2012, 10:26:25 pm »
I just finished following the official SFML tutorial perfectly, but I still get this problem.

Code: [Select]
fatal error LNK1104: cannot open file 'sfml-graphics-s-d.lib'

I switched to Dynamic linking and tried the same thing, and got the same error "sfml-graphics-d.lib." It also does the same thing in Release mode, with both Dynamic and Static linking. I've triple checked that the compiler has the include and lib directories like the tutorial shows.

I checked on the forums, and it seems people with this problem were told that they didn't correctly link the libraries.
Perhaps I'm not linking the libraries correctly, but I did exactly what the tutorial said to do.

It's my fifth time trying to install SFML with VC++ 2010 Express :-(
I'm running Windows Vista 32-bit and already used CMake and nmake on the SFML files (I'm using SFML 2.0) and everything up to there worked fine.

Anyone know what the problem is?
« Last Edit: August 03, 2012, 09:14:40 am by Pikmeir »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Can't get VC++ to run with SFML
« Reply #1 on: August 02, 2012, 10:56:22 pm »
There's no magic in VS. If VS says it can't open that lib file, then there are only two possibilities:
  • VS couldn't find the library.
  • VS doesn't have access to it (not enough rights or something else is blocking it).

Since the second one is rather unlikely I'd say that you still somehow setup something wrong. :-\

You're mentioning you've tried once the dynamic and once the static libraries for debuging, do you also have compiled the debug libraries?
You have to run the library compilation twice once for debug and once for release.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Pikmeir

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Can't get VC++ to run with SFML
« Reply #2 on: August 02, 2012, 11:07:01 pm »
There's no magic in VS. If VS says it can't open that lib file, then there are only two possibilities:
  • VS couldn't find the library.
  • VS doesn't have access to it (not enough rights or something else is blocking it).

Since the second one is rather unlikely I'd say that you still somehow setup something wrong. :-\

You're mentioning you've tried once the dynamic and once the static libraries for debuging, do you also have compiled the debug libraries?
You have to run the library compilation twice once for debug and once for release.

I ran nmake, and the tutorial didn't say I had to compile it twice (for VC++), and since the default of nmake is 'all'. Are there other special instructions that aren't in the tutorial? Like, do I have to run nmake -d or something like that again?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Can't get VC++ to run with SFML
« Reply #3 on: August 02, 2012, 11:21:59 pm »
Why did you compile SFML? There's a precompiled release candidate (if we're talking about SFML 2).

If you followed the CMake tutorial, there's this paragraph:
Quote
CMAKE_BUILD_TYPE
This option selects the build type. Relevant values are "Debug" and "Release" (there are other types such as "RelWithDebInfo" or "MinSizeRel", but they are not really configured in the SFML makefiles). Note that if you generate a workspace for an IDE that supports multiple configurations, such as Visual Studio, this option is ignored and you automatically get all the available build types in it.
Which clearly implies that for a single build, you get a single variant of the SFML libraries. With single-configuration generators (nmake, make, ...) you must create separate builds for each configuration. With multi-configuration generators (Visual Studio, Code::Blocks) you'll get all configurations in one build, but you still need to compile each of them.

When you get an error which says "cannot open file", the first thing to do is obviously to check whether the file is there or not (never trust an error message). If the file doesn't exist, then ask yourself "why?". This may not give you the answer, but at least you know a little more about what's wrong :)
« Last Edit: August 02, 2012, 11:24:36 pm by Laurent »
Laurent Gomila - SFML developer

Pikmeir

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Can't get VC++ to run with SFML
« Reply #4 on: August 03, 2012, 12:06:50 am »
I checked if the missing dll file was there, but I couldn't find it either in the \lib folder. I guess it never properly installed, even though I followed the steps. But I won't give up yet, I'll try to do everything again from the beginning using the official tutorial. If it doesn't work this next time I'm just gonna pay somebody to remote control my PC and do it for me  >:(


edit: I did it again, this time using the SFML SDK for Visual C++ 2010 (Express). I really wish someone would remake that tutorial, because it's so hard to understand (some parts are super easy to understand, but some parts kind of gloss over the details and assume the user has experience compiling other APIs). I have no experience compiling other APIs and the instructions really confuse me, but I still followed them as perfectly as I could. Still, the basic code example won't compile in Debug or in Release :'(
« Last Edit: August 03, 2012, 12:58:39 am by Pikmeir »

Raptor88

  • Full Member
  • ***
  • Posts: 111
    • View Profile
    • Email
Re: Can't get VC++ to run with SFML
« Reply #5 on: August 03, 2012, 01:30:38 am »
It's my fifth time trying to install SFML with VC++ 2010 Express :-(
I'm running Windows Vista 32-bit and already used CMake and nmake on the SFML files (I'm using SFML 2.0) and everything up to there worked fine.

Anyone know what the problem is?

I don't know what your particular problem is since I'm just a beginner myself.  But I too had problems installing SFML in VC++ 2010 Express.  Here' a link to that thread and a step-by-step procedure of what I did to get it to work.

http://en.sfml-dev.org/forums/index.php?topic=8285.msg56024#msg56024

Hope it helps your problem,
Raptor

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10815
    • View Profile
    • development blog
    • Email
Re: Can't get VC++ to run with SFML
« Reply #6 on: August 03, 2012, 02:22:04 am »
As Laurent stated here and in the other thread, if you follow the tutorial 1:1, without doing anything else or jumping over a paragraph/word, you'll end up with a working enviroment. There are no extra steps needed. ;)

It's also adviced to understand the capabilities of your IDE and how things work.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Pikmeir

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Can't get VC++ to run with SFML
« Reply #7 on: August 03, 2012, 02:24:11 am »
I'll post the steps I'm doing exactly, one at a time, so hopefully someone can see if I'm doing something wrong (or missing something). I'll do this exactly as the official tutorial says to do.

1) Download SFML 2.0 Release Candidate (Windows 32 bits - Visual C++ 2010) and extract it (I put it in C:\sfml\)

2) Make a new 'Win32 Project' in Visual C++ 2010

3) Select 'Empty Project' and click 'Finish'

4) Add a main.cpp to the project, and fill it with example project from the tutorial (found here: http://www.sfml-dev.org/tutorials/2.0/start-vc.php)

6) Project Properties -> Configuration -> "All Configurations"

7) Configuration Properties -> C/C++ -> General -> Additional Include Directories -> "C:\sfml\SFML-2.0-rc\include"

8) Configuration Properties -> Linker -> General -> Additional Library Directories -> "C:\sfml\SFML-2.0-rc\lib"

9) Configuration -> "Debug"

10) Configuration Properties -> Linker -> Input -> Additional Dependencies -> added "sfml-main-d.lib; sfml-graphics-d.lib; sfml-window-d.lib; sfml-system-d.lib; sfml-audio-d.lib; sfml-network-d.lib;" (I added main because it's a Windows application)

11) Configuration -> "Release

12) Configuration Properties -> Linker -> Input -> Additional Dependencies -> added "sfml-main.lib; sfml-graphics.lib; sfml-window.lib; sfml-system.lib; sfml-audio.lib; sfml-network.lib;"

13) Copied all 10 library files to the same folder as main.cpp (12 files copied total, including both sfml-main files)

------------------------------

Try compiling with Debug.
I get this error:

Code: [Select]
1>  main.cpp
1>sfml-main-d.lib(SFML_Main.cpp.obj) : warning LNK4099: PDB 'sfml-main-d.pdb' was not found with 'sfml-main-d.lib(SFML_Main.cpp.obj)' or at 'c:\users\username\documents\visual studio 2010\Projects\MyProject\Debug\sfml-main-d.pdb'; linking object as if no debug info
1>sfml-main-d.lib(SFML_Main.cpp.obj) : warning LNK4099: PDB 'sfml-main-d.pdb' was not found with 'sfml-main-d.lib(SFML_Main.cpp.obj)' or at 'c:\users\username\documents\visual studio 2010\Projects\MyProject\Debug\sfml-main-d.pdb'; linking object as if no debug info
1>  MyProject.vcxproj -> c:\username\mycomputer\documents\visual studio 2010\Projects\MyProject\Debug\MyProject.exe
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========

Try compiling with Release.
I get this error:

Code: [Select]
'MyProject.exe': Loaded 'C:\Users\username\Documents\Visual Studio 2010\Projects\MyProject\Release\MyProject.exe', Symbols loaded.
'MyProject.exe': Loaded 'C:\Windows\System32\ntdll.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\kernel32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\sfml-graphics-2.dll', Binary was not built with debug information.
'MyProject.exe': Loaded 'C:\Windows\System32\sfml-system-2.dll', Binary was not built with debug information.
'MyProject.exe': Loaded 'C:\Windows\System32\msvcrt.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\MinGW\bin\libgcc_s_dw2-1.dll', Binary was not built with debug information.
'MyProject.exe': Loaded 'C:\MinGW\bin\libstdc++-6.dll', Binary was not built with debug information.
'MyProject.exe': Loaded 'C:\Windows\System32\sfml-window-2.dll', Binary was not built with debug information.
'MyProject.exe': Loaded 'C:\Windows\System32\gdi32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\user32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\advapi32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\rpcrt4.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\opengl32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\glu32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\ddraw.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\dciman32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\setupapi.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\oleaut32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\ole32.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\dwmapi.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\winmm.dll', Cannot find or open the PDB file
'MyProject.exe': Loaded 'C:\Windows\System32\oleacc.dll', Cannot find or open the PDB file
Debugger:: An unhandled non-continuable exception was thrown during process load

If I just try to run it anyway in Debug, it'll tell me:
"This application has failed to start because sfml-graphics-d-2.dll was not found. Re-installing the application may fix this problem."

If I just try to run it anyway in Release, it'll tell me:
"The procedure entry point ??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IABUContextSettings@1@@Z could not be located in the dynamic link library sfml-graphics-2.dll."


So, what should I reinstall? Did I make some mistake in following the instructions?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Can't get VC++ to run with SFML
« Reply #8 on: August 03, 2012, 08:11:56 am »
Quote
I really wish someone would remake that tutorial, because it's so hard to understand (some parts are super easy to understand, but some parts kind of gloss over the details and assume the user has experience compiling other APIs). I have no experience compiling other APIs and the instructions really confuse me, but I still followed them as perfectly as I could.
I'd be glad to see your feedback and improve the tutorial accordingly.

And it's still not clear what you're trying to do. Do you compile SFML or do you install the precompiled package? Please be careful about the words that you use ;)

Quote
Try compiling with Debug.
I get this error:
Quote
[...]
Rebuild All: 1 succeeded [...]
Read the compiler output carefully, and don't hesitate to find information about the warnings that you get. Some of them, like this one, is not an error. It just says that you don't have the debug symbols of SFML libraries, which is true: they are not included in the precompiled packages. And this won't have any effect on your program.

Quote
Try compiling with Release.
I get this error:
Quote
[...]
Debugger:: An unhandled non-continuable exception was thrown during process load
This is a runtime error, which means that your program compiled and linked ok.
Here we can see that you run the app with the debugger, which is obviously wrong since this is a release build :)
And make sure that you're not using debug libraries in release mode (or vice versa).

Quote
If I just try to run it anyway in Debug, it'll tell me:
"This application has failed to start because sfml-graphics-d-2.dll was not found. Re-installing the application may fix this problem."
This is explained at the end of the tutorial, read it again carefully.

Quote
If I just try to run it anyway in Release, it'll tell me:
"The procedure entry point ??0RenderWindow@sf@@QAE@VVideoMode@1@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@IABUContextSettings@1@@Z could not be located in the dynamic link library sfml-graphics-2.dll."
This means that your sfml-graphics-2.dll doesn't match the .lib file that you used when you compiled your app. A different version (like an old 2.0), or the version for a different compiler (VC++ 2008 or gcc).
Laurent Gomila - SFML developer

Pikmeir

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Can't get VC++ to run with SFML
« Reply #9 on: August 03, 2012, 08:41:48 am »
The first time I compiled it, and that's what I posted on my error. But I just recently tried to use the SFML RC 2.0 and still wasn't able to make it work.

If I can make it work, I'd love to give my feedback for the installation tutorial to make it better to help other people who are struggling to get it working. I think SFML is the best (simple) API out there for so it'd be great if more people could try it.

I'm surprised you can understand what all of the errors mean! I'm going to try again one more time.
After reading your comment on the last one, it might be a problem because I'd previously installed SFML and have been using it with MinGW for the past couple of months, so perhaps VC++ is locating my old dll files (which I'd copied into system32.
Thanks for your help.

Pikmeir

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Can't get VC++ to run with SFML
« Reply #10 on: August 03, 2012, 09:14:27 am »
I tried it again, and took your suggestion to just ignore the errors that I was getting (at least some of those ones), and it works now!!!

Perhaps for the tutorial, I suggest it would be better to give more information on using sfml-main, since it's a bit confusing the way it explains why to use it. I think it'd be better to just say "we recommend you add sfml-main.lib and sfml-main-d.lib (for the Debug) to these libraries" at the same part where it lists which library files to add, instead of at the very end of the tutorial. It could have a simple explanation why, but it was a bit confusing to read that because I thought, "if I add sfml-main, what does it mean? Do I still put int WinMain()? or something else? Do I have to add it?"

Also for the first image in the VC++ tutorial, it should put a red box around "All Configurations." Even though it says that above, I forgot to do it because I was focused on the picture when I saw it. Maybe this is just a problem I had though.

It also says, toward the end of the tutorial, "don't forget to copy the SFML DLLs (they are in <sfml-install-path/bin>) to the directory where your compiled executable is." However, this is still a little vague, since VC++ creates multiple folders for the same project. I was wondering, "If I link dynamically, then do I put these .dlls in the main folder of the project, or in the sub-folder that contains main.cpp? Or, in the individual Release and Debug folders that VC++ creates?" It might be easier to just say "put them in the same folder as main.cpp is located"

Anyway, I'm not going to blame the tutorial for any mistakes. It's always my fault for not knowing more about programming. But thanks to your help I was able to make it work finally. ( Finally :D )

Thank you for your help again!
« Last Edit: August 03, 2012, 09:18:28 am by Pikmeir »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Can't get VC++ to run with SFML [Solved]
« Reply #11 on: August 03, 2012, 09:34:54 am »
Thank you very much for your detailed feedback about the tutorial :)

The first two points can easily be made clearer, you're right.

However:
Quote
It also says, toward the end of the tutorial, "don't forget to copy the SFML DLLs (they are in <sfml-install-path/bin>) to the directory where your compiled executable is." However, this is still a little vague, since VC++ creates multiple folders for the same project. I was wondering, "If I link dynamically, then do I put these .dlls in the main folder of the project, or in the sub-folder that contains main.cpp? Or, in the individual Release and Debug folders that VC++ creates?" It might be easier to just say "put them in the same folder as main.cpp is located"
You probably didn't understand "the directory where your compiled executable is". It really means: where your .exe is created by the compiler. So this is very precise and not vague at all ;)
And this is not where main.cpp or your project file is.

And this makes me realize that I forgot to tell about the working directory, which is different if you run the executable from the IDE rather than from the explorer.
Laurent Gomila - SFML developer

Pikmeir

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Can't get VC++ to run with SFML [Solved]
« Reply #12 on: August 03, 2012, 09:40:44 am »
I guess I should've thought about "compiled executable" a little more. It was vague to me when I first read it, but maybe only because I was frustrated trying to make it work. When I read it now, it does make sense :P
Thank you again for your help.

 

anything