【发布时间】:2021-08-28 00:22:27
【问题描述】:
我正在尝试编译一个需要 libpthreads.so 的包。我的系统(Ubuntu 20.04)有 libpthread.so(线程末尾没有's')。
我尝试将 libpthreads.so 链接到 libpthread.so,但 ldconfig 无法识别新文件。我这样做了:
> cd /lib/x86_64-linux-gnu
> ln -s libpthread-2.31.so libpthreads.so
> rm /etc/ld.so.cache
> ldconfig
我运行了几次“ldconfig”,然后检查它是否找到了新库:
> ldconfig -p | grep libpthrea
libpthread.so.0 (libc6,x86-64, OS ABI: Linux 3.2.0) => /lib/x86_64-linux-gnu/libpthread.so.0
libpthread.so (libc6,x86-64, OS ABI: Linux 3.2.0) => /lib/x86_64-linux-gnu/libpthread.so
为什么 ldconfig 没有找到新的库(它只找到了原来的 libpthread.so,而不是 libpthreads.so)?
我也尝试制作副本(而不是符号链接),但这没有帮助。
文件所在的目录(/lib/x86_64-linux-gnu)对于链接器来说是已知的:
> ld --verbose | grep SEARCH_DIR | tr -s ' ;' \\012
SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu")
SEARCH_DIR("=/lib/x86_64-linux-gnu") <---- this directory
SEARCH_DIR("=/usr/lib/x86_64-linux-gnu")
SEARCH_DIR("=/usr/lib/x86_64-linux-gnu64")
SEARCH_DIR("=/usr/local/lib64")
SEARCH_DIR("=/lib64")
SEARCH_DIR("=/usr/lib64")
SEARCH_DIR("=/usr/local/lib")
SEARCH_DIR("=/lib")
SEARCH_DIR("=/usr/lib")
SEARCH_DIR("=/usr/x86_64-linux-gnu/lib64")
SEARCH_DIR("=/usr/x86_64-linux-gnu/lib")
【问题讨论】:
标签: ubuntu linker shared-libraries ld