gpt4 book ai didi

macos - dyld:库未加载...原因:未找到图像

转载 作者:行者123 更新时间:2023-12-01 18:32:18 26 4
gpt4 key购买 nike

当尝试运行在 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”粘贴到那里时,它不再介意它了。不幸的是,它提示找不到下一个 boost 库。

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

最佳答案

查找所有 boost 库(其中 exefile 是可执行文件的名称):

$ otool -L exefile
exefile:
@executable_path/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

对于每个libboost_xxx.dylib,执行:

$ install_name_tool -change @executable_path/libboost_something.dylib /opt/local/lib/libboost_something.dylib exefile

最后再次使用otool进行验证:

$ otool -L exefile
exefile:
/opt/local/lib/libboost_something.dylib (compatibility version 0.7.0, current version 0.7.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 65.1.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 169.3.0)

联机帮助页:otool install_name_tool

编辑不久前,我编写了一个Python脚本(copy_dylibs.py)来在构建应用程序时自动解决所有这些问题。它将把 /usr/local/opt/local 中的所有库打包到应用程序包中,并修复对这些库的引用以使用 @rpath。这意味着您可以使用 Homebrew 轻松安装第三方库并同样轻松地打包它们。

我现在已将此脚本公开于 github .

关于macos - dyld:库未加载...原因:未找到图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17703510/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com