当我试图在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)修复了这个问题,这使得一个新的清洁构建,真的很奇怪。

其他回答

Xcode 11.1 & Swift 5.1

快速修复

首先确保外部添加的库有选项embed被选择在General Tab, embdbbinaries。

如果还是不行…

出现这种情况是因为存在不同的、不匹配的库版本。

更新Pods

pod update

重要提示:检查所有库都包含在构建设置->库和框架列表中,并且您已经在构建中嵌入了选项

工作非常棒

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

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

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

这应该可以解决问题

brew update
brew upgrade
brew cleanup

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

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