无法链接共享对象

时间:2015-09-17 11:19:37

标签: c++ buildroot ldd

我在将应用程序链接到共享对象时遇到问题。我已经干净地构建了buildroot,包括host-thrift和host-openssl。

ldd --verbose libthrift.so产生以下结果:

./libthrift.so: /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libcrypto.so.1.0.0: no version information available (required by ./libthrift.so)
./libthrift.so: /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libssl.so.1.0.0: no version information available (required by ./libthrift.so)
./libthrift.so: /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libssl.so.1.0.0: no version information available (required by ./libthrift.so)
    linux-vdso.so.1 =>  (0x00007ffda06bc000)
    libssl.so.1.0.0 => /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libssl.so.1.0.0 (0x00007f0c37c10000)
    libcrypto.so.1.0.0 => /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libcrypto.so.1.0.0 (0x00007f0c377d9000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f0c375bb000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f0c3723f000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f0c36f39000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f0c36b74000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f0c3695d000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f0c36759000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f0c38129000)

    Version information:
    ./libthrift.so:
        libgcc_s.so.1 (GCC_3.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
        libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
        libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libstdc++.so.6 (CXXABI_1.3.1) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
        libstdc++.so.6 (GLIBCXX_3.4.9) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
        libstdc++.so.6 (CXXABI_1.3) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
        libstdc++.so.6 (GLIBCXX_3.4) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
        libpthread.so.0 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libpthread.so.0
        libpthread.so.0 (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/libpthread.so.0
        libcrypto.so.1.0.0 (OPENSSL_1.0.0) => not found
        libssl.so.1.0.0 (OPENSSL_1.0.1) => not found
        libssl.so.1.0.0 (OPENSSL_1.0.0) => not found
    /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libssl.so.1.0.0:
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
    /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libcrypto.so.1.0.0:
        libdl.so.2 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libdl.so.2
        libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.7) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libpthread.so.0:
        ld-linux-x86-64.so.2 (GLIBC_2.2.5) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
    /usr/lib/x86_64-linux-gnu/libstdc++.so.6:
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
        libm.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libm.so.6
        libgcc_s.so.1 (GCC_4.2.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
        libgcc_s.so.1 (GCC_3.3) => /lib/x86_64-linux-gnu/libgcc_s.so.1
        libgcc_s.so.1 (GCC_3.0) => /lib/x86_64-linux-gnu/libgcc_s.so.1
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.18) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.4) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.17) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.3.2) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libm.so.6:
        libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libc.so.6:
        ld-linux-x86-64.so.2 (GLIBC_2.3) => /lib64/ld-linux-x86-64.so.2
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
    /lib/x86_64-linux-gnu/libgcc_s.so.1:
        libc.so.6 (GLIBC_2.14) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6
    /lib/x86_64-linux-gnu/libdl.so.2:
        ld-linux-x86-64.so.2 (GLIBC_PRIVATE) => /lib64/ld-linux-x86-64.so.2
        libc.so.6 (GLIBC_PRIVATE) => /lib/x86_64-linux-gnu/libc.so.6
        libc.so.6 (GLIBC_2.2.5) => /lib/x86_64-linux-gnu/libc.so.6

这表明有些可疑的东西:

./libthrift.so: /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libcrypto.so.1.0.0: no version information available (required by ./libthrift.so)
./libthrift.so: /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libssl.so.1.0.0: no version information available (required by ./libthrift.so)
./libthrift.so: /home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/libssl.so.1.0.0: no version information available (required by ./libthrift.so)

据我所知,当您构建新版本的库而非您尝试运行的库时,可能会发生这种情况。但这不是这里的情况(除非主持人的图书馆正在播放我看不到的技巧)。

此外:

libcrypto.so.1.0.0 (OPENSSL_1.0.0) => not found
libssl.so.1.0.0 (OPENSSL_1.0.1) => not found
libssl.so.1.0.0 (OPENSSL_1.0.0) => not found

然而,这些文件存放在同一个文件夹中。

我尝试了什么:

1

使用LD_LIBRARY_PATHLIBRARY_PATH不会影响此问题,因为libthrift.so是使用rpath构建的:

readelf -a libthrift.so | grep PATH
0x000000000000000f (RPATH)              Library rpath: [/home/ano/workspace/source/open-source/buildroot/output/host/usr/lib]

2

检查文件类型:

> file libthrift.so
libthrift.so: symbolic link to `libthrift-0.9.2.so'

> file libthrift-0.9.2.so
libthrift-0.9.2.so: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2dd133dea99a83cd5a8a9873e91503df3b7d7359, not stripped

> file libssl.so.1.0.0 
libssl.so.1.0.0: ELF 64-bit LSB  shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=52c9028d053f16d05b6e1ff35605019182c8b28d, not stripped

第3。 (新信息)

将我的本地/lib/x86_64-linux-gnu/libcrypto.so.1.0.0/lib/x86_64-linux-gnu/libssl.so.1.0.0复制到/home/ano/workspace/source/open-source/buildroot/output/host/usr/lib/

这个确实修复了这个问题,所以现在,如果我理解正确,似乎当libthrift.so是在buildroot中构建时,它使用我的本地/lib库而不是由buildroot本身构建的那些。

1 个答案:

答案 0 :(得分:2)

结果是buildroot中的host-thrift包中的错误。 host-thrift声明了对host-boost的依赖关系,但没有为主机构建指定--with-boost--with-boost-libdir配置选项。

我将HOST_THRIFT_CONF_OPTS设置为:

HOST_THRIFT_CONF_OPTS = --with-sysroot=$(HOST_DIR) \
    --with-boost \
    --with-boost-libdir=$(HOST_DIR)/usr/lib \
    --disable-tests \
    --disable-tutorial

并解决了这个问题。