Re: link shared libs independent of lib version
From: Paul Pluzhnikov (ppluzhnikov-nsp_at_charter.net)
Date: 04/24/04
- Next message: Barry Margolin: "Re: Linux election polling station script"
- Previous message: GVK: "Re: strtok vs split"
- In reply to: Tim: "Re: link shared libs independent of lib version"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 24 Apr 2004 08:14:22 -0700
timoteo@pacbell.net (Tim) writes:
> > Link against libstdc++ statically, and everything else dynamically.
> > See the thread above for details.
>
> Thanks Paul. I can't say I understood everything in the thread, but I
> think I get what I need to do. ldd shows dependence on:
> libstdc++.so.3
> libm.so.6
> libgcc_s.so.1
> libc.so.6
> /lib/ld_linux.so.2
>
> Do I understand correctly
No.
> that if I link statically to libstdc++ and dynamically to
> everything else, then, I won't run into problems
There is one more "undesirable" library on the list above -- libgcc_s.
You need to remove that dependency as well. Fortunately, there is
a flag for that: -static-libgcc
> with e.g., a system that doesn't have libc.so.6?
Every Linux distribution (that I know of) made after 1996 has
libc.so.6. I don't think you need to worry about it not being there.
> I get that point for static linking. I meant with respect to my user
> setting up a symbolic link to make the lib on his system appear to be
> the one my app was looking for. Are you saying we were only lucky
> that appears to be working properly?
If you link statically, it already doesn't work (on some systems).
If you link dynamically, it will work, but your users may have to
set things up (create missing links, install libstdc++.so.5, etc).
Your goal is make the app work "out of the box" (at least that's
what I understood as your goal). In order to get to that goal,
eliminate libstdc++ and libgcc_s dependency.
> BTW, the source code will build as either .c or .cpp. Would building
> it as C code make any difference on these issues?
Yes: if you build the app as 'C', and add -static-libgcc, your app
should work "out of the box" on all machines that have the same or
later glibc installed on them (that is, you don't have to worry
about libstdc++ anymore).
Cheers,
-- In order to understand recursion you must first understand recursion. Remove /-nsp/ for email.
- Next message: Barry Margolin: "Re: Linux election polling station script"
- Previous message: GVK: "Re: strtok vs split"
- In reply to: Tim: "Re: link shared libs independent of lib version"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|