SFML community forums
Help => General => Topic started by: Disch on May 02, 2010, 07:30:52 pm
-
Hello all.
I'm trying to statically link to SFML 1.6 on Ubuntu. I'm using GCC with the Code::Blocks IDE.
I have built both static and dynamic builds of SFML. Linking with the dynamic version works fine, but linking with the static version brings up all sorts of linker errors... as if I were failing to link to some other necessary libraries.
Some friends of mine on IRC were giving me some help. One of them gave me to a link to a blog which seemed to suggest that I would have to find and dynamically link to all of sfml's dependencies.
Here is the link they gave me:
http://indicium.us/site_blog/2010/03/gccg-mixed-static-and-dynamic-linking.html
Obviously this is not ideal.
Is that really necessary? Can't I just statically link to SFML, but still have SFML dynamically link to all its dependencies? Surely something so basic can't be all that complicated (then again... this is Linux so you never know)
-
Is that really necessary?
It is. When building a static library, no link is done, a static library is just an archive of object files. That's why you have to link to every library that SFML would have linked to otherwise.
Just don't use static linking on Linux, it's not how things work with this OS.
-
Is that really necessary?
It is. When building a static library, no link is done, a static library is just an archive of object files. That's why you have to link to every library that SFML would have linked to otherwise.
Blech. That's stupid.
Oh well. I can live with it I guess.
Thanks.
-
Some libraries provide a pkg-config script that automatically appends the dependencies to the linker command line. But I don't know how to write such a script, and I don't want to.
-
If that's now how things work on Linux, are you supposed to specify SFML as a requirement to run your program?
-
If that's now how things work on Linux, are you supposed to specify SFML as a requirement to run your program?
Yes. Typically on Linux your package manager handles all of the dependencies, though.
-
If that's now how things work on Linux, are you supposed to specify SFML as a requirement to run your program?
Yes, more specifically, if it's dynamically linked.
@Disch, if you want it "statically linked" but dynamically linked to the dependency libraries, you could include SFML's files in your project, then add the appropriate dynamic linker commands (to the dependencies). Then just compile it like that. I'm not sure if the (SFML) license allows this or not though.