Results 1 to 5 of 5

Thread: compiling clanLib app on linux - shared objects

  1. #1

    Question compiling clanLib app on linux - shared objects

    Hi everyone,

    I'm using clanLib 3.0 on linux (ubuntu 13.04). I compiled and installed clanLib successfully and done some very simple programs to become familiar with this library, and I really like it.
    But I'm generally new in c++ programming (I have expirience with php and java), what I mean is I know the language at sufficient level (and I'm learning fast :P), I know and understand OOP, some design patterns etc etc... But what I don't understand:
    I see the clanLib is compiled into shared libraries (.so files). So when I put my executables on another machine and try to run it, it tells me that some shared objects are missing. As I read, the shared object is something similar to windows .dll. But under windows, clanlib for ms VS is compiled into .lib files which seem to be a static libraries (?).

    So, do I need to have this clanLib shared libraries with my executable on each machine I want it to work? Or maybe there is some way to compile it with this libraries into one executable containing everything it needs to run?

    What are this .so files in comparation to windows .dll's or .lib's of VS?

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    You are correct, .so files are the Linux equivalent of .dll files under Windows.

    You could copy all the .so dependency files and bundle them with your executable (similar to placing DLL files next to the exe in Windows), but in practice this is often difficult to do properly. What most binary distributions do instead is to link statically do the libraries they use. The Windows version of ClanLib is always a static library, while the Linux version currently can be built both dynamically and statically.

    To link statically, you add the --static command line option to GCC when you link your executable. You may also need to add some parameter to ./configure when building ClanLib. I am not entirely sure of the details (maybe Rombust knows).

  3. #3
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I've never done it.

    I've always assumed that "make" creates both the shared and static libraries

    I can't check at the moment

    Personally, I would recommend always linking with static.

    Note, even when linking with static, we still use dlsym to dynamically load "libGL.so.1", since it depends on the installed graphics drivers.

  4. #4

    Default

    Thanks for you replies,

    It all gets more clear to me now. Since I read what Judas wrote, I am looking for more information about static and dynamic linking through google. I tried compile it with -static param, and I got an error:
    Code:
    Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
    So I tried to find something about it, without success. And it fits into what you said about the "libGL.so.1", but I don't know how to do it.
    Could you explain, like to fool (), what do you mean by "use dlsym" and how to link this particular library dynamically, please?

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Try .. " -static -static-libgcc -static-libstdc++ "

    But ... http://www.akkadia.org/drepper/no_static_linking.html

    Googling around suggests do not static link!

    However, you still should be able to do it, without "-static"
    by manually linking in the compiled clanlib libraries.

    With everything else (excluding clanlib) dynamic linking

Similar Threads

  1. Compiling on linux
    By Fasox in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 12-26-2011, 11:04 AM
  2. Problem compiling Examples on GNU/Linux
    By SpartanJ in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 02-25-2009, 05:17 PM
  3. Constructing ClanLib 0.9 Objects
    By rombust in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 12-21-2008, 08:27 AM
  4. Installing ClanLib 0.8 and ClanLib 0.9 on linux
    By rombust in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-15-2008, 09:51 AM
  5. Help compiling ClanLib
    By Shauni in forum Official ClanLib SDK Forums
    Replies: 7
    Last Post: 06-28-2007, 12:53 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •