当我试图在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 '在那里,它不再介意了。不幸的是,它会抱怨找不到下一个增强库。

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


当前回答

我通过使用产品>清洁构建文件夹(CommandShiftK)修复了这个问题,这使得一个新的清洁构建,真的很奇怪。

其他回答

要解决我的Macbook Catalina 10.15.4上的以下错误:

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
    Referenced from: /usr/local/bin/mongoexport
    Reason: image not found
Abort trap: 6

我运行下面的命令,解决了上面的问题:

brew switch openssl 1.0.2s

您可以对可执行文件使用otool命令和-L选项,这将显示可执行文件期望这些库的位置。

如果需要更改这些库的路径,请使用install_name_tool命令,该命令允许您设置库的路径。

我通过使用产品>清洁构建文件夹(CommandShiftK)修复了这个问题,这使得一个新的清洁构建,真的很奇怪。

我通过重新安装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)”

快速修复

删除pod(其名称在错误中)通过在Podfile中注释它,如#Podname 运行pod安装 取消注释之前注释过的pod 再次运行pod install。

这对我来说很有效,所以分享它很容易。