Apt

無法載入共享庫“libdl.so”或其依賴項之一

  • May 4, 2022

我正在嘗試編譯一個項目,但由於缺少庫而導致編譯失敗。

System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl.so: cannot open shared object file: No such file or directory
at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLinuxLibraryImplementation.dlopen(String fileName, Int32 flags)
at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLinuxLibraryImplementation.NativeLoadLibrary(String path)
at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLibraryImplementation.LoadLibrary(String path)
at Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary(String libPath)
at Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary()
at Assimp.Unmanaged.UnmanagedLibrary.LoadIfNotLoaded()
at Assimp.Unmanaged.AssimpLibrary.CreatePropertyStore()
at Assimp.AssimpContext.CreateConfigs()
at Assimp.AssimpContext.PrepareImport()
at Assimp.AssimpContext.ImportFile(String file, PostProcessSteps postProcessFlags)
at Microsoft.Xna.Framework.Content.Pipeline.OpenAssetImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\OpenAssetImporter.cs:line 291
at Microsoft.Xna.Framework.Content.Pipeline.FbxImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\FbxImporter.cs:line 24
at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\ContentImporter.cs:line 45
at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\Builder\PipelineManager.cs:line 669

我一直在 github、Google、Stackoverflow、askubuntu 和此處的 MonoGame 問題跟踪器中尋找已知的解決方案。

檢查我的系統時,如果該文件確實存在,sudo find / -iname libdl.so但找不到該文件。在裡面/usr/lib/i386-linux-gnu/usr/lib/x86_64-linux-gnu我可以找到一個libdl.so.2聽起來相關的文件。

https://packages.ubuntu.com/search?suite=trusty&arch=any&searchon=contents&keywords=libdl.so上,我可以看到該libdl.so文件包含在libc6-dev我已經安裝但重新安裝的包中,但沒有任何運氣。

這是結果sudo apt-config dump | grep APT::Architecture

APT::Architecture "amd64";
APT::Architectures "";
APT::Architectures:: "amd64";
APT::Architectures:: "i386";

這是結果dpkg-query --list libc6

Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version         Architecture Description
+++-==============-===============-============-=================================
ii  libc6:amd64    2.34-0ubuntu3.2 amd64        GNU C Library: Shared libraries
ii  libc6:i386     2.34-0ubuntu3.2 i386         GNU C Library: Shared libraries

我正在執行 Pop!_OS 21.10 64 位。

我可以做些什麼來獲取libdl.so文件,甚至可以以健康和受支持的方式?

第一步,您應該檢查建構需要哪些庫(具有確切版本)。

dl庫現在是 C 標準庫的一部分。發行說明告訴你,從你的版本 2.34 開始,

…以前在庫 libpthread、libdl、libutil、libanl 中實現的所有功能都已集成到 libc 中。新應用程序不再需要與 -lpthread、-ldl、-lutil、-lanl 連結。為了向後兼容,提供了空的靜態存檔 libpthread.a、libdl.a、libutil.a、libanl.a,以便連結器選項繼續工作。與 glibc 2.33 或更早版本連結的應用程序繼續載入相應的共享對象(現在為空)。

這意味著您必須選擇較舊版本的libc庫(2.34 之前),通常在較舊的作業系統版本上,或者如果您知道自己在做什麼,請調整您的 Makefile(以刪除顯式libdl.so要求)。

引用自:https://unix.stackexchange.com/questions/700097