Use RPATH to point to libc library

I need to deploy my shared library (.so) in an ancient linux distro (CentOS 6.5).

The problem is that I'm actually compiling my code using CentOS 7 (gcc 4.8.2) and the libc versions are different.

My code depends on the GLIBC 2.14, however, the newest GLIBC version at CentOS 6.5 is 2.13.

I would like to use the RPATH mechanism and deploy the libc files along with the shared library file (.so).

Is this even possible?

What I did so far

I've created a directory containing:

$ ls ld-linux-x86-64.so.2 libc.so.6 libgcc_s.so.1 libm.so.6 libstdc++.so.6

-static-libgcc and -static-libstdc++

These help with the problem of GLIBCXX. However, the GLIBC version problem remains:

/lib64/libc.so.6: version `GLIBC_2.14' not found (required by sss_reactions/libsss_reactions.so)

--rpath and --dynamic-linker

Using the readelf utility I saw that the RPATH was correctly set, and calling ldd on the library also points to the correct directory (containing the newer libc).

However, when I try to load the library with dlopen() I get the same error:

/lib64/libc.so.6: version `GLIBC_2.14' not found (required by sss_reactions/libsss_reactions.so)

Setting LD_LIBRARY_PATH

In this case, I get this error:

$ LD_LIBRARY_PATH=../dist/ ./Dlopen ./Dlopen: relocation error: ../dist/libc.so.6: symbol _dl_starting_up, version GLIBC_PRIVATE not defined in file ld-linux-x86-64.so.2 with link time reference


I would like to use the RPATH mechanism and deploy the libc files along with the shared library file (.so).

Is this even possible?

No, it's not, for reasons explained here.

See also this answer for what's involved in having multiple instances of libc.so.6 coexist on a single host.

链接地址: http://www.djcxy.com/p/46448.html

上一篇: 运行时链接程序,将父路径添加到解析路径

下一篇: 使用RPATH指向libc库