SFML community forums
Help => General => Topic started by: MDK on February 21, 2017, 06:47:00 pm
-
I can't run example code. When i'm compiling it, i have this message:
||=== Build: Debug in sfml-project01 (compiler: GNU GCC Compiler) ===|
ld.exe||cannot find -lsfml-graphics|
ld.exe||cannot find -lsfml-window|
ld.exe||cannot find -lsfml-system|
||error: ld returned 1 exit status|
||=== Build failed: 4 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|
I did everything as is said in this tutorial: https://www.sfml-dev.org/tutorials/2.0/start-cb.php
Additionally:
I downloaded and installed this: TDM 4.9.2 (64-bit), codeblocks-16.01-setup.exe, source code of sfml 2.4.2 and made sfml with cmake. Then I created new project, new file.cpp, copied code, and after compilation I had those error messages. After that I followed few YouTube tutorials, tried static and non static version of configuration and nothing changed
I have Windows 10 64bit if this is important.
Here are pics of configuration:
(http://i65.tinypic.com/nog35z.jpg)
(http://i67.tinypic.com/npjhvk.jpg)
(http://i66.tinypic.com/f00nq1.jpg)
-
Just a quick thought - what is the contents of C:/SFML/lib? Have you moved the compiled libraries to this folder you refer to in C::B?
-
When i was ask if path to te lib should be relative, i answered no. So i think, this should be full path to the folder where i have all files, that was made by cmake from SFML 2.4.2.. This folder is C:\SFML.
-
And what's the content of the directory?
-
/bin/openal32.dll
/cmake/Modules/FindSFML.cmake
/include/SFML/Audio,Graphics,Network,System,Window folders, and header files
/lib/*.a
/license.txt
/readme.txt
-
Don't make assumptions about how things work on Windows based on your experience with Linux, or rather don't give out advice based on these assumptions. ;)
MinGW (GCC) still uses .a files for static libs and import/definition libraries.
So what are the names of these *.a files?
-
(http://i66.tinypic.com/2e6817l.jpg)
-
So how do you expect GCC to find "sfml-graphics" if your directory only contains "sfml-graphics-s"? ;)
If you want to link the static version, you have to add the -s suffix and define SFML_STATIC.
-
I did everything like on this tutorial:https://www.youtube.com/watch?v=0LGzJP3k7M4
And now have this:
(http://i66.tinypic.com/ajq7hu.jpg)
Can problem be somewhere else, because i checked it twice doing above. And why my directory contain only -s versions of these files?
-
The error message is pretty clear. It can't find the specified libraries. And you know why it can't find it, because they don't exist in the specified location.
If you for example just build the static release (-s) set of SFML libraries you'll just have that one version of them. If you now also want the static debug (-s-d) set of SFML libraries, you'll have to adjust the CMake settings and build that set.
In other words, CMake doesn't build all possible variations, but just the one you specify.
-
That solved the problem with missing debug files. But now I have another one. After compiling project there is something like that:
(http://i67.tinypic.com/2dij4tl.jpg)
I thought that this could be problem with downloaded file, so I redownloaded it and CMake it again. And outcome is the same. Then I downloaded this ready to use file:GCC 4.9.2 TDM (SJLJ) - 64-bit and same thing happened. I am starting to believe in this Murphy law: Anything That Can Possibly Go Wrong, Does.
-
Read the official tutorial again. Especially the part about linking statically. Make sure it's for the latest SFML version.
-
Yes: Starting from SFML 2.2, when static linking, you will have to link all of SFML's dependencies to your project as well.
Thanks for help and for your patience.
-
There were a few missing dependencies in the tutorial for me, namely "jpeg" and I think one or two others.
This is a good list to start with:
sfml-graphics-s
freetype
jpeg
sfml-window-s
opengl32
gdi32
sfml-system-s
winmm
Do not include the file extensions or even path if you are using Code::Blocks and following the tutorial. Just type these in as-is. That tripped me up for a while.
To my knowledge, all of those were required to compile that program for me on windows. I may be wrong about freetype, but jpeg is for sure.
-
They are all listed in the tutorial, you just have to read the latest tutorial. ;)