在执行时强制使用特定库

时间:2017-06-22 07:51:36

标签: c linux gcc

我使用选项编译可执行文件以使用特定库(而不是系统库)。编译还可以。

但是当我执行这个二进制文件时,尽管已指定cols = ['A','B'] #if mixed values - numeric with strings bulb_temp_df[cols]=bulb_temp_df[cols].astype(str) bulb_temp_df[cols]=bulb_temp_df[cols].apply(lambda x:x.str.extract('(\d+\.\d+)',expand=False) .astype(float) .fillna(0)) A B 0 10.1 33.3 1 11.2 44.2 2 12.3 11.3 3 14.2 0.0 4 15.4 0.0 指向这些特定的库,但我在LD_LIBRARY_PATH上发生错误,发现libc的错误版本:

glib

正常情况下可执行使用系统./bin: /lib/i386-linux-gnu/libc.so.6: version `GLIBC_2.17' not found (required by /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libglib-2.0.so.0) 而非特定libc ...可执行文件上的libc显示问题:

ldd

[user ~/Desktop/gesram_x86 ] ldd -v bin ./bin: /lib/i386-linux-gnu/libc.so.6: version `GLIBC_2.17' not found (required by /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libglib-2.0.so.0) linux-gate.so.1 => (0xb7704000) libgesram.so.0 => /home/user/Desktop/gesram_x86/gesram/lib_gesram/.libs/libgesram.so.0 (0xb76f9000) libsofutils.so.0 => /home/user/ptxdist/platform-i586/sysroot-target/applications/base/lib/libsofutils.so.0 (0xb76f1000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7531000) libglib-2.0.so.0 => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libglib-2.0.so.0 (0xb7403000) libgio-2.0.so.0 => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libgio-2.0.so.0 (0xb721b000) libgobject-2.0.so.0 => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libgobject-2.0.so.0 (0xb71bc000) libffi.so.6 => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libffi.so.6 (0xb71b3000) libpcre.so.1 => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libpcre.so.1 (0xb713b000) libgmodule-2.0.so.0 => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libgmodule-2.0.so.0 (0xb7137000) libz.so.1 => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libz.so.1 (0xb711c000) librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb7112000) libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb70f6000) /lib/ld-linux.so.2 (0xb7705000) libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb70f1000) Version information: ./bin: libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /home/user/Desktop/gesram_x86/gesram/lib_gesram/.libs/libgesram.so.0: libpthread.so.0 (GLIBC_2.0) => /lib/i386-linux-gnu/libpthread.so.0 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /home/user/ptxdist/platform-i586/sysroot-target/applications/base/lib/libsofutils.so.0: librt.so.1 (GLIBC_2.2) => /lib/i386-linux-gnu/librt.so.1 libpthread.so.0 (GLIBC_2.0) => /lib/i386-linux-gnu/libpthread.so.0 libc.so.6 (GLIBC_2.3.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.8) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /lib/i386-linux-gnu/libc.so.6: ld-linux.so.2 (GLIBC_2.3) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2 /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libglib-2.0.so.0: libpthread.so.0 (GLIBC_2.12) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_2.2) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_2.1) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_2.0) => /lib/i386-linux-gnu/libpthread.so.0 libc.so.6 (GLIBC_2.9) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.11) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.8) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.7) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.15) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.17) => not found libc.so.6 (GLIBC_2.1.2) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.3.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/i386-linux-gnu/libc.so.6 /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libgio-2.0.so.0: libz.so.1 (ZLIB_1.2.2) => /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libz.so.1 libpthread.so.0 (GLIBC_2.2) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_2.0) => /lib/i386-linux-gnu/libpthread.so.0 libc.so.6 (GLIBC_2.9) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.2) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.12) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.14) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.3.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_PRIVATE) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.5) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libgobject-2.0.so.0: libc.so.6 (GLIBC_2.3.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libffi.so.6: libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.7) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libpcre.so.1: libpthread.so.0 (GLIBC_2.0) => /lib/i386-linux-gnu/libpthread.so.0 libc.so.6 (GLIBC_2.3.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.3) => /lib/i386-linux-gnu/libc.so.6 /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libgmodule-2.0.so.0: libpthread.so.0 (GLIBC_2.0) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_2.2) => /lib/i386-linux-gnu/libpthread.so.0 libdl.so.2 (GLIBC_2.1) => /lib/i386-linux-gnu/libdl.so.2 libdl.so.2 (GLIBC_2.0) => /lib/i386-linux-gnu/libdl.so.2 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /home/user/ptxdist/platform-i586/sysroot-target/usr/lib/libz.so.1: libc.so.6 (GLIBC_2.1) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.4) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.3.4) => /lib/i386-linux-gnu/libc.so.6 /lib/i386-linux-gnu/librt.so.1: libpthread.so.0 (GLIBC_2.1) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_PRIVATE) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_2.0) => /lib/i386-linux-gnu/libpthread.so.0 libpthread.so.0 (GLIBC_2.2) => /lib/i386-linux-gnu/libpthread.so.0 libc.so.6 (GLIBC_2.3.2) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_PRIVATE) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /lib/i386-linux-gnu/libpthread.so.0: ld-linux.so.2 (GLIBC_2.1) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 ld-linux.so.2 (GLIBC_2.3) => /lib/ld-linux.so.2 libc.so.6 (GLIBC_2.3.2) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_PRIVATE) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.2) => /lib/i386-linux-gnu/libc.so.6 /lib/i386-linux-gnu/libdl.so.2: ld-linux.so.2 (GLIBC_PRIVATE) => /lib/ld-linux.so.2 libc.so.6 (GLIBC_PRIVATE) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1.3) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.1) => /lib/i386-linux-gnu/libc.so.6 libc.so.6 (GLIBC_2.0) => /lib/i386-linux-gnu/libc.so.6 /lib/库的所有链接都是错误的...

这是我的编译命令:

/usr/lib/

这是在执行时强制使用特定库的方法吗?

LD_DEBUG输出的一部分=全./bin(谢谢Ctx):

/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/bin/i586-unknown-linux-gnu-gcc -o bin fichier.c -I/home/user/include -I/home/usr/ptxdist/platform-i586/sysroot-target/usr/include/glib-2.0/ -Wl,-rpath,gesram/lib_gesram/.libs/ -Lgesram/lib_gesram/.libs/ -lgesram -Wl,-rpath,/home/user/ptxdist/platform-i586/sysroot-target/applications/base/lib/ -L/home/user/ptxdist/platform-i586/sysroot-target/applications/base/lib/ -lsofutils -Wl,-rpath,/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-gnu/usr/lib/ -L/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-gnu/usr/lib/ -lc -Wl,-rpath,/home/user/ptxdist/platform-i586/sysroot-target/usr/lib/ -L/home/user/ptxdist/platform-i586/sysroot-target/usr/lib/ -lglib-2.0 -lgio-2.0 -lgobject-2.0 -lffi -lpcre -lgmodule-2.0 -lz

我不明白为什么可执行文件不使用此文件 24006: file=libc.so.6 [0]; needed by ./bin [0] 24006: find library=libc.so.6 [0]; searching 24006: search path=/home/ggau/Desktop/gesram_x86/gesram/lib_gesram/.libs:/home/ggau/integration/ptxdist/platform-i586/sysroot-target/applications/base/lib:/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-g [...] 24006: trying file=/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-gnu/lib/sse2/libc.so.6 24006: trying file=/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-gnu/lib/cmov/libc.so.6 24006: trying file=/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-gnu/lib/libc.so.6 24006: search cache=/etc/ld.so.cache 24006: trying file=/lib/i386-linux-gnu/libc.so.6 24006: 24006: file=libc.so.6 [0]; generating link map 24006: dynamic: 0xb77a4d7c base: 0xb75fd000 size: 0x001abadc 24006: entry: 0xb7616690 phdr: 0xb75fd034 phnum: 10 ,因为它是好文件......

/opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-gnu/lib/libc.so.6

在尝试lrwxrwxrwx 1 root root 12 May 31 17:45 /opt/OSELAS.Toolchain-2016.06.0/toolchain-i586/sysroot-i586-unknown-linux-gnu/lib/libc.so.6 -> libc-2.23.so* ...

之前尝试此文件

1 个答案:

答案 0 :(得分:2)

简而言之,您不能强迫应用程序使用您自己的GLIBC,而无需为此GLIBC提供原生的动态链接器。

64位:

-Wl,--rpath=<path to glibc 64-bit libs>
-Wl,--dynamic-linker=<path to glibc 64-bit libs>/ld-linux-x86-64.so.2

32位:

-Wl,--rpath=<path to glibc 32-bit libs>
-Wl,--dynamic-linker=<path to glibc 32-bit libs>/ld-linux.so.2