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

Author Topic: Statically linking to SFML on Ubuntu  (Read 4801 times)

0 Members and 1 Guest are viewing this topic.

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Statically linking to SFML on Ubuntu
« 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)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Statically linking to SFML on Ubuntu
« Reply #1 on: May 02, 2010, 07:48:00 pm »
Quote
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.
Laurent Gomila - SFML developer

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
Statically linking to SFML on Ubuntu
« Reply #2 on: May 02, 2010, 09:47:14 pm »
Quote from: "Laurent"
Quote
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.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Statically linking to SFML on Ubuntu
« Reply #3 on: May 02, 2010, 10:40:59 pm »
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.
Laurent Gomila - SFML developer

Overv

  • Newbie
  • *
  • Posts: 9
    • View Profile
Statically linking to SFML on Ubuntu
« Reply #4 on: June 24, 2010, 04:35:54 pm »
If that's now how things work on Linux, are you supposed to specify SFML as a requirement to run your program?

pdusen

  • Newbie
  • *
  • Posts: 30
    • View Profile
Statically linking to SFML on Ubuntu
« Reply #5 on: June 24, 2010, 07:48:45 pm »
Quote from: "Overv"
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.

Recruit0

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Statically linking to SFML on Ubuntu
« Reply #6 on: June 24, 2010, 08:58:02 pm »
Quote from: "Overv"
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.

 

anything