SFML community forums

Help => General => Topic started by: Andrew on May 23, 2014, 12:49:47 am

Title: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 12:49:47 am
Hello,

I had a project in Visual Studio 2012 with working code that used SFML-2.1. I updated it to Visual Studio 2013 and quickly discovered that I needed to get the 2013 version of SFML libraries. Here are a few of the errors I got:


(click to show/hide)


I would much prefer to simply download and use them, however there's no 2013 version on the SFML website and the only files I found for it in the forums were dynamic; I'm using the static libraries.

I got CMake gui to work properly using the tutorial: configure, configure, generate, etc. No problems. I used the VC++12 compiler option or whatever (version 12 is for VS2013).

Then I opened it in VS2013, built the debug and release libraries, copied them over into my now 2013 project, updated the include header files for SFML as well, and tried to run it. I got a whole bunch of linker errors that I have never seen before, which seem to be related to SFML's dependencies now. Here are a few:


(click to show/hide)


Just for the heck of it I tried adding this line to my code:

#pragma comment(lib, "OpenGL32.lib")

The GL errors seem to go away, and now I seem to get GLEW errors. Is it possible that this statement in the CMake tutorial:

Quote
On Windows and Mac OS X, all the needed dependencies are provided directly with SFML, so you don't have to download/install anything. Compilation will work out of the box.

would somehow not be true? I followed the tutorial by the letter, I'm confident I did not miss anything, I triple checked that I used the updated version of SFML's include header files and library files, I tried running in release and debug mode, etc. What should I do?

Thanks,

- Andrew
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Ixrec on May 23, 2014, 12:59:16 am
A while back static linking was changed so that more (all?) of the dependencies have to be specified manually.  I believe https://github.com/SFML/SFML/wiki/FAQ#build-link-static is the closest thing we have at the moment to an official list of what exactly needs to be added to the link line.  Presumably the official tutorials for 2.2 will clarify this.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 01:13:12 am
Okay, so, from looking at that diagram I conclude that if I'm going to link network, audio, window, and graphics, I'll need to also link: ws2_32, openal32, sndfile, opengl32, gdi32, freetype, glew, and jpeg. Is this correct?

Also, is this linking supposed to happen in the VS2013 binaries solution (where I build the 2013 SFML libraries), or do I need to link in my actual project? Do I just need to add them to the link input list? Etc.

Thanks,

- Andrew
Title: Re: CMake Libraries Version/Dependency Problem
Post by: G. on May 23, 2014, 01:14:20 am
In your actual project. Same place you link sfml-graphics-s etc.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 01:38:48 am
Is there any practical way I would be able to combine all of these libraries into one, then?
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 02:08:24 am
Alright I give up. 2012 it is...
Title: Re: CMake Libraries Version/Dependency Problem
Post by: zsbzsb on May 23, 2014, 04:52:53 pm
Is there any practical way I would be able to combine all of these libraries into one, then?

No  ??? this wouldn't even make sense to do.

Alright I give up. 2012 it is...

Come SFML 2.2 and static linking you will be doing the exact same thing in 2012, so why not just do it now and get over it?
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 07:46:06 pm
Because now there isn't sufficient information or support for how to do it.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Nexus on May 23, 2014, 07:57:45 pm
Because now there isn't sufficient information or support for how to do it.
There's a whole tutorial that explains every single step of building SFML for any platform. Then there are nightly builds. There are various threads on this forum and additional hints on the Wiki. Some people have even written their installers to make the task of building SFML even easier. And of course there's a whole community answering specific questions. You call that insufficient information?

In programming, you won't get around doing a bit of research to achieve your goals. I really recommend you learn how to properly build SFML, then you know it once and forever. This knowledge can be very valuable, as SFML might not be the last library you're using. And building SFML is really not as difficult as you might imagine. However, it's crucial that you read the tutorial and other advice carefully. A lot of people quickly glance over it, miss important details and waste a tremendous amount of time debugging -- much more than they saved in the first place.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Jesper Juhl on May 23, 2014, 08:04:56 pm
Seriously, building SFML from source is trivial compared to most other stuff. Just learn it once and for all.

In a nutshell it's basically just
 - git clone
 - mkdir build
 - cd build
 - cmake ..
 - make
 - sudo make install

and you're done. Takes maybe 5-10 minutes (tops).
Details differ by platform, but that's the gist of it; clone the repo, generate build files, build, install ...

Try something like building the Linux kernel, X.org, glibc, Qt, dcmtk and similar some day - not that they are hard, but just that in comparison; SFML is a walk in the park.
You might as well learn your way around the preprocessor, compiler & linker as well as tools such as CMake, SCons, make, msbuild etc. and (d)vcs tools like svn, git, mercurial and the like, sooner rather than later if you are serious about building software.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 08:52:23 pm
What I mean is there isn't sufficient information about the dependencies. All it does is list a bunch of libraries, some of which aren't even found in the extlibs folder.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Jesper Juhl on May 23, 2014, 08:55:10 pm
All the dependencies are free open source libraries. A quick Google search locates them all.
On Linux all you have to do is just install them via your package manager since most distros ship them. On Windows and other "challenged" platforms you may have to download and build them yourself, but even then they are not hard to find.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 09:30:37 pm
My point is just that I use SFML so I don't have to deal with problems like this. I understand that the change was made for good reasons, whatever they are, but now it's losing its ease of use for those who use VS2013 or other currently unsupported compilers/IDE's. Believe me though, I understand the extent as to how much coding can be a hassle; I just like to avoid it wherever possible. For now, I'd rather just use VS2012 so I can continue working on my own code.

Another problem with the switch is that if I use SFML in more than one project, I now have to copy a bunch of libraries and link all of them.

I'll give it another shot when I have time.
Title: AW: CMake Libraries Version/Dependency Problem
Post by: eXpl0it3r on May 23, 2014, 09:34:45 pm
For Windows and OS X all the dependencies are provided in the extlibs directory.

Besides that it's not SFML's job nor goal to teach people how to generally build, link and inter-link libraries. This is general C++ development knowledge that needs to be acquired differently.

Still we try to make things as easy as possible and if you have specific suggestions on how to improve the tutorials, we'd be happy to hear them.
Title: Re: AW: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 10:01:11 pm
For Windows and OS X all the dependencies are provided in the extlibs directory.

Are you sure about that? Because I didn't find all of the ones listed in the link Ixrec mentioned (https://github.com/SFML/SFML/wiki/FAQ#build-link-static).
Title: Re: CMake Libraries Version/Dependency Problem
Post by: eXpl0it3r on May 23, 2014, 10:31:15 pm
If you can't find the ones with a name listed there, then it's a system library, which surprise, surprise don't need to be shipped, since they are available on system level.

SFML ships with: freetype, glew, jpeg, openal32 and libsndfile
For Windows the system libs that are used additionally are: winmm, ws2_32, gdi32 and opengl32
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on May 23, 2014, 10:48:19 pm
Ahh okay. Thanks guys.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: StormWingDelta on May 24, 2014, 04:42:05 pm
hmm I wonder if the installer for SFML still works for the current version?  ??? Maybe it would solve a lot of problems we keep seeing pop up. :)
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Laurent on May 24, 2014, 11:05:38 pm
The ones you don't find are system libraries, shipped with your compiler.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: DxE on May 30, 2014, 06:04:38 pm
I'm having a related issue with static linking, I'm pretty certain I've done something wrong but wish to clarify if my (release) linker setup should look like:

opengl32.lib
ws2_32.lib
gdi32.lib
winmm.lib
freetype.lib
sndfile.lib
glew.lib
jpeg.lib
openal32.lib
sfml-main.lib
sfml-system-s.lib
sfml-window-s.lib
sfml-graphics-s.lib

I should maybe also note that the only 'unresolved blah blah blah' errors I'm getting are related to sfml-window-s.lib:

(click to show/hide)

Also I have a dynamic linking problem which I believe only occurs on integrated graphics hardware where sf::Text stuff causes the program to crash, which is why I'm trying to statically link in the first place as reading around led me to believe this was only an issue with dynamically linked libraries. I imagine that's an issue for another thread though.

EDIT: I'm using Visual Studio 2013
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Jesper Juhl on May 30, 2014, 06:09:07 pm
What hardware your app (and sfml) will run on shouldn't have anything to do with how you link.
How you link only affects what your runtime dependencies are. Not the capabilities of the final binary at runtime.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: DxE on May 30, 2014, 06:26:24 pm
I apologise in advance, I'm rather uninformed when it comes to linking in general and I dug around for the thread that I (misinterpreted) that led me to believe dynamic linking is the issue: http://en.sfml-dev.org/forums/index.php?topic=3976.0

Basically my issue matches up closely with the 3rd post (2nd reply), being that my app runs and closes fine on my desktop and several of my friends' but crashes on my own laptop and college's desktop computers, both of which use use Intel's integrated graphics processors, when I close the application. Notably that thread is about an SFML 2 issue and this is about  SFML 2.1.

I've made a separate thread for the issue to avoid clogging up this one:
http://en.sfml-dev.org/forums/index.php?topic=15399.0
Title: Re: CMake Libraries Version/Dependency Problem
Post by: DxE on May 30, 2014, 06:31:51 pm
I should maybe also note that the only 'unresolved blah blah blah' errors I'm getting are related to sfml-window-s.lib:

I switched back to Debug configuration and got more errors, looks more like stuff in the OP this time:
(click to show/hide)
Title: AW: CMake Libraries Version/Dependency Problem
Post by: eXpl0it3r on June 01, 2014, 01:06:16 pm
__imp_XYZ and dllspec etc implies that you're trying to link/build it against/for a shared library.

Did you declare SFML_STATIC?
Title: Re: CMake Libraries Version/Dependency Problem
Post by: DxE on June 02, 2014, 12:41:50 am
I think so? Whether I did it right or not is another matter:
(http://puu.sh/9b4qh.png)
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Laurent on June 02, 2014, 07:48:31 am
You're showing your Release settings. You said you had problems in Debug mode.
Title: Re: CMake Libraries Version/Dependency Problem
Post by: DxE on June 02, 2014, 07:15:18 pm
Oops, my bad. I added SFML_STATIC to debug however errors (different ones) cropped up and I was still having errors when compiling the release build anyway so I've assumed there is some flaw in my programming or linker setup that I've overlooked and can't remember.

I set up a second, smaller and simpler program with the debug build set up to statically link and the release build to dynamically link and both work... Most of the time.

With the following code:
(click to show/hide)

This happens with the Debug (statically linked) build: http://puu.sh/9c2Eo.png
This happens with the Release (dynamically linked) build: http://puu.sh/9c2T4.png

The following images are of my settings in the Debug build configuration:
Directories: http://puu.sh/9c2W9.png
Pre-Processor: http://puu.sh/9c2Yc.png
Code Generation: http://puu.sh/9c2ZH.png
Linker Input: http://puu.sh/9c32l.png

Does this just mean I haven't compiled SFML correctly, or is there a flaw in my linker settings?
Title: Re: CMake Libraries Version/Dependency Problem
Post by: Andrew on June 02, 2014, 11:54:34 pm
Is this even related to my CMake/VS2013 problem anymore? If not, can you make a new thread? I don't want to get emails about other people's problems unless I'm helping them or they're undergoing the same situation and solving it.