[lug] Need help understanding linking and loading shared libraries

Zan Lynx zlynx at acm.org
Tue Feb 5 10:37:17 MST 2008


On Mon, 2008-02-04 at 17:41 -0700, Michael Hirsch wrote:
> I thought I mostly understood this, but I'm definitely missing something.
> 
> I have a library, lets call it libboost.so.1.33.1, though the real
> name is longer.  There is also a copy of this file named libboost.so
> 
> I build my own library, lets call it libfoo.so which relies on
> libboost.  The option to g++ is -lboost.
> 
> Finally, I have an executable, bar, that needs libfoo.so (again, with -lfoo).
> 
> All this works.  But now, if I only have libboost.so and not
> libboost.so.1.33.1 the loader will complain that it can't file
> libboost.so.1.33.1.  In fact, "ldd bar" reports libboost.so.1.33.1,
> rather than libboost.so like I expected.


Check that your .so isn't actually a linker script.  For example, here
is /usr/lib/libacl.so from my system:


/* GNU ld script
   Since Gentoo has critical dynamic libraries
   in /lib, and the static versions in /usr/lib,
   we need to have a "fake" dynamic lib in /usr/lib,
   otherwise we run into linking problems.

   See bug http://bugs.gentoo.org/4411 for more info.
 */
OUTPUT_FORMAT ( elf64-x86-64 )
GROUP ( /lib64/libacl.so )

Also, I have Boost installed but no libboost.so anywhere, only the
separate parts of Boost like libboost_thread.so, etc.  I understand that
you may have shortened the name though.
-- 
Zan Lynx <zlynx at acm.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.lug.boulder.co.us/pipermail/lug/attachments/20080205/7863ddb4/attachment.pgp>


More information about the LUG mailing list