SFML community forums
Help => General => Topic started by: shaidyn on March 15, 2015, 11:46:53 pm
-
Now, before you direct me to the tutorials or google, I've gone through those carefully. There's obviously something simple I'm missing, and I'm hoping you can point it out. :)
I have a small SFML project that was working previously, and is no longer. Here are the details:
The solution file is located at: G:\Entertainment\Programming_Projects\Point_and_Click.
There is a folder in this directory that holds the SFML files called "SFML-2.2".
The "Active config" for the solution is "Release|Win32".
In the Properties, I have the C++ > General > Additional Include Directories set to:
G:\Entertainment\Programming_Projects\Point_and_Click\SFML-2.2\include
C++ > Code Generation > Runetime Library is /MD
C++ > Preprocessor > Preprocessor Definitions includes SFML_STATIC at the top.
Linker > General > Additional Library Directories is:
G:\Entertainment\Programming_Projects\Point_and_Click\SFML-2.2\lib
Linker > Input > Additional Dependencies (for Release) are:
sfml-graphics-s.lib
sfml-audio-s.lib
sfml-network-s.lib
sfml-window-s.lib
sfml-system-s.lib
If I go to the location I've indicated (G:\Entertainment\Programming_Projects\Point_and_Click\SFML-2.2\lib), all of the applicable .lib files are there.
When I attempt to compile the solution in Visual Studio 2013, I get around 90 errors that say roughly the same thing:
"error LNK2001: Unresolved external symbol".
I tried compiling without using the -s at the end of the .lib files, and only got one LNK2001 error. I'd greatly appreciate any and all help.
-
Since SFML 2.2, if you compile your project with SFML's static libs, you also need to link its dependencies.
-
before you direct me to the tutorials or google, I've gone through those carefully
Really? Then...
sfml-graphics-s.lib
sfml-audio-s.lib
sfml-network-s.lib
sfml-window-s.lib
sfml-system-s.lib
Wouldn't be all the libs you are linking to if you followed the tutorials so carefully.
I mean, its only in a big red block in the corresponding tutorial (http://www.sfml-dev.org/tutorials/2.2/start-vc.php) for the compiler you are using.
Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well. This means that if you are linking sfml-window-s.lib or sfml-window-s-d.lib for example, you will also have to link opengl32.lib, winmm.lib and gdi32.lib. Some of these dependency libraries might already be listed under "Inherited values", but adding them again yourself shouldn't cause any problems.
(yes, it really is in red)
-
Thank you for the reply, zsbzsb.
Google had lead me to http://www.sfml-dev.org/tutorials/2.0/start-vc.php. I didn't think that the difference between 2.2 and 2.0 would be so much as to push the tutorial out of date, and that was my bad assumption.
Thanks for the help.
-
Hi again, folks!
I'm coming back to this because I've encountered a related issue, and didn't want to clog the boards with a new thread.
I was able to get a release build using static linking, by adding all of the additional libraries. But I'm running into an issue when I try to create a debug build. Specifically:
Unhandled exception at 0x77E122D2 (ntdll.dll) in Point_and_Click.exe: 0xC0000005: Access violation writing location 0x00000004.
I did some searching on google, and it's mentioned that I may be mixing release and debug libraries. My additional dependencies look like this:
sfml-graphics-s-d.lib
sfml-audio-s-d.lib
sfml-network-s-d.lib
sfml-window-s-d.lib
sfml-system-s-d.lib
winmm.lib
ws2_32.lib
sndfile.lib
openal32.lib
opengl32.lib
gdi32.lib
glew.lib
freetype.lib
jpeg.lib
I tried changing the latter ones to include a -d, but I then got this error:
cannot open file 'winmm-d.lib', so I suspect that's not the case.
I'm fairly certain it's an issue with my debug vs release configuration, because the code itself compiles and runs happily in release mode.
-
As long as you are building your own project in debug mode you should be good. Any chance you could try compiling the basic example from the getting started tutorials (http://www.sfml-dev.org/tutorials/2.2/start-vc.php) (at the very end)?
The error is because something somewhere trying to access a null pointer... so there is a chance you did something wrong in your code - also make sure you that SFML was compiled for your compiler (that really doesn't seem to be the case here though).