Ubuntu在哪里寻找共享库?
当我运行一个在运行时链接到共享库的进程(在进程启动时链接,之后没有用dlload()
链接),它在哪里查找除LD_LIBRARY_PATH
之外的共享库( .so
)文件?
背景:
我有一些使用特定第三方库编写的C ++代码。 我已经安装了库并在两个不同的平台上编译了我的代码,包括Ubuntu但不同版本,以及不同版本的gcc。 该库是从源代码编译和安装的,位于两个平台上的/usr/local/lib
。 当我编译我的代码时,我链接到第三方库的pkg-config --libs
参数,我已经validation了pkg-config --libs
在两个平台上都返回完全相同的东西。
我的代码在两个平台上都成功编译,并且LD_LIBRARY_PATH
在两个平台上都没有定义(或定义为空: ""
)。 但是,当我在一个平台上运行它时工作正常,另一方面我得到这个错误:
error while loading shared libraries: libthrift-0.9.0.so: cannot open shared object file: No such file or directory
有趣的是,那些不起作用的是Ubuntu和gcc的新版本。 :/
所以我试图找出工作人员如何能够找到库,以便我可以使破坏的库以相同的方式找到库。 (即,没有设置LD_LIBRARY_PATH
)
更新:
这是cat /etc/ld.so.conf.d/*
的输出cat /etc/ld.so.conf.d/*
……在工作(旧)系统上:
/usr/lib/mesa /usr/lib32/mesa /usr/lib/alsa-lib # libc default configuration /usr/local/lib # Multiarch support /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu
…在破碎的(较新的)系统上:
# libc default configuration /usr/local/lib # Multiarch support /lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu /usr/lib/x86_64-linux-gnu/mesa
整个路径业务与称为多拱的事物有关。 基本上,它允许您在同一系统上拥有32位和64位库。
复制文件后,您是否碰巧运行了ldconfig?
ldconfig creates, updates, and removes the necessary links and cache (for use by the run-time linker, ld.so) to the most recent shared libraries found in the directories specified on the command line, in the file /etc/ld.so.conf, and in the trusted directories (/usr/lib and /lib). ldconfig checks the header and file names of the libraries it encounters when determining which versions should have their links updated. ldconfig ignores symbolic links when scanning for libraries.