dynamic linking with stdc++ (was: Re: ghci dynamic linking)

skaller skaller at users.sourceforge.net
Wed May 9 21:05:47 EDT 2007

On Wed, 2007-05-09 at 23:44 +0100, Frederik Eaton wrote:

> I think the problem is that there is a /usr/lib/libstdc++.so.5 and a
> /usr/lib/libstdc++.so.6 but no /usr/lib/libstdc++.so; when I created
> the latter, linking to the libstdc++.so.6 link, I was able to use ghci
> with my package. I wish I knew why /usr/lib/libstdc++.so is missing,
> but it is missing on 4 out of 4 of the computers I just now checked so
> I think it is normal for it to be missing, and the problem probably
> lies with ghci?

Libraries are utterly incompatible:
they use a different Application Binary Interface (ABI).
The ABI changed around starting gcc 3.4 I think.

Examining a binary on my amd64 Ubuntu/Linux box:

skaller at rosella:/work/felix/svn/felix/felix/trunk$ ldd bin/flx_run
        libflx_pthread_dynamic.so => not found
        libflx_dynamic.so => not found
        libflx_gc_dynamic.so => not found
        libdl.so.2 => /lib/libdl.so.2 (0x00002b7ba1854000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00002b7ba1a59000)
        libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x00002b7ba1c74000)
        libm.so.6 => /lib/libm.so.6 (0x00002b7ba1f78000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00002b7ba21fb000)
        libc.so.6 => /lib/libc.so.6 (0x00002b7ba2409000)
        /lib64/ld-linux-x86-64.so.2 (0x00002b7ba1637000)

you can see:

* my application libs are not found (LD_LIBRARY_PATH not set)
* compiler libraries use *.so.integer links
* core libs use *.so.integer links
* the dynamic loader is hard coded

skaller at rosella:/work/felix/svn/felix/felix/trunk$ ls /usr/lib/libstd*
/usr/lib/libstdc++.so.5      /usr/lib/libstdc++.so.6
/usr/lib/libstdc++.so.5.0.7  /usr/lib/libstdc++.so.6.0.8

skaller at rosella:/work/felix/svn/felix/felix/trunk$ ls -l /usr/lib/libdl*
-rw-r--r-- 1 root root 13162 2007-04-04 21:06 /usr/lib/libdl.a
lrwxrwxrwx 1 root root    15 2007-04-20 03:20 /usr/lib/libdl.so
-> /lib/libdl.so.2

Note here the '/usr/lib/libdl.so' links to '/lib/libdl.so.2':
it's a core lib, not a compiler lib. Finally see:

skaller at rosella:/work/felix/svn/felix/felix/trunk$ ls
-l /usr/lib/gcc/x86_64-linux-gnu/4.1.2/libstdc++*

/lib/gcc/x86_64-linux-gnu/4.1.2/libstdc++.so -> ../../../libstdc++.so.6

so the link 'libstdc++.so' does exist .. but it is in a compiler
specific location.

John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

More information about the Glasgow-haskell-users mailing list