当我试图在Mac OS X中运行一个可执行文件时,我得到以下错误

dyld: Library not loaded: libboost_atomic.dylib
  Referenced from: /Users/"Directory my executable is in"
  Reason: image not found
Trace/BPT trap:5

我已经安装了boost库,它们位于/opt/local/lib中。我认为这个问题与可执行文件只在它所在的目录中查找有关,因为当我粘贴'libboost_atomic。Dylib '在那里,它不再介意了。不幸的是,它会抱怨找不到下一个增强库。

有没有简单的方法来解决这个问题?


当前回答

在我们的例子中,它是一个基于Xcode 11.5构建的iOS应用,使用cocoapods(如果你愿意,也可以是cocoapods-binary)。

我们看到了这样的崩溃:

dyld: Library not loaded: @rpath/PINOperation.framework/PINOperation
  Referenced from: /private/var/containers/Bundle/Application/4C5F5E4C-8B71-4351-A0AB-C20333544569/Tellus.app/Frameworks/PINRemoteImage.framework/PINRemoteImage
  Reason: image not found

原来我必须删除pod缓存并重新运行pod安装,所以Xcode会指出这个差异:

其他回答

可以使用sudo install_name_tool -change change dylib路径 和 Sudo install_name_tool -id change dylib名称

Install_name_tool -add_rpath new_path可执行文件 Install_name_tool -delete_rpath old_path可执行文件

如https://gist.github.com/berkedel/d1fc6d13651c16002f64653096d1fded中所说,你可以试试

brew uninstall --ignore-dependencies node icu4c
brew install node
brew link --overwrite node

我通过重新安装Homebrew解决了这个问题

卸载

ruby -e "$(curl - ssl https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"

安装

ruby / usr / bin / e,“美元(卷毛-fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

我忘记添加use_frameworks了!在我的播客里。我把它加回来,它起作用了。