Dav*_*hun 33 shared-library libraries dynamic-linking
当我运行一个在运行时链接到共享库的进程(在进程启动时链接,稍后不与 链接dlload()
)时,.so
除了LD_LIBRARY_PATH
?
背景:
我编写了一些使用特定第三方库的 C++ 代码。我已经在两个不同的平台上安装了这个库并编译了我的代码,都是 Ubuntu 但不同的版本,以及不同版本的 gcc。该库是从源代码编译和安装的,位于/usr/local/lib
两个平台上。当我编译我的代码时,我链接了pkg-config --libs
第三方库的参数,并且我已经验证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
Run Code Online (Sandbox Code Playgroud)
有趣的是,那那些没有工作,是新的Ubuntu和gcc版本。:/
所以我试图弄清楚工作人员如何能够找到图书馆,以便我可以让坏的人以同样的方式找到图书馆。(即,没有设置LD_LIBRARY_PATH
)
更新:
这是我的输出 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
Run Code Online (Sandbox Code Playgroud)
...在损坏的(较新的)系统上:
# 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
Run Code Online (Sandbox Code Playgroud)
hoo*_*enz 36
这整个路径业务与称为多拱的东西有关。基本上它允许您在同一系统上拥有 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.
Run Code Online (Sandbox Code Playgroud)
小智 9
上述问题和第一个(也是唯一的 ATT)答案中包含的信息帮助我解决了我在WSL Ubuntu(在 Win10 64 上)上的*类似*问题!
就我而言,可执行文件找不到库。我最终注意到新创建的库位于 中/usr/lib64
,但的多架构行/etc/ld.so.conf.d/x86_64-linux-gnu.conf
不包含该目录。
所以我跑了
sudo ldconfig /usr/lib64
最终解决了这个问题。(在没有目录参数的情况下单独运行它并没有让它“神奇地”找到库顺便说一句。)目前还不清楚“重新启动”我的 WSL bash 是否有帮助......我认为这甚至不需要。
归档时间: |
|
查看次数: |
72546 次 |
最近记录: |