gpt4 book ai didi

c++ - 无法链接共享对象

转载 作者:行者123 更新时间:2023-11-30 03:49:19 26 4
gpt4 key购买 nike

我在将我的应用程序链接到共享对象时遇到问题。我已经干净地构建了 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 自己构建的库。

最佳答案

原来是buildroot中host-thrift包的bug。 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

这就解决了问题。

关于c++ - 无法链接共享对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32629071/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com