无法使用犰狳运行编译的 cpp 代码,因为 dyld:库未加载
Can't run compiled cpp code with armadillo, because of dyld: Library not loaded
我按照这里的安装说明(Mac OS(进行操作:
https://gitlab.com/conradsnicta/armadillo-code/#5-linux-and-macos-installation
我成功编译了示例代码,如下所示:
http://arma.sourceforge.net/docs.html#example_prog
由
g++ example1.cpp -o example1 -O2 -larmadillo
然后我尝试运行输出,但出现以下错误:
dyld: Library not loaded: @rpath/libhdf5.101.dylib
Referenced from: /usr/local/lib/libarmadillo.9.dylib
Reason: image not found
Abort trap: 6
有什么想法如何让它工作吗?
在构建应用程序时,您需要-rpath
链接器选项来告诉加载程序在何处查找该库。
通常,Mac应用程序是它自己的文件夹树,称为捆绑包。在那里,您将放置库文件,然后在应用程序二进制文件中列出@executable_path/relative_path_to_library
,作为加载程序看到@rpath
时查看的位置。
延伸阅读: 运行路径相关库
我在犰狳上遇到了完全相同的错误。我所做的是首先卸载犰狳(这可能不是必需的(。然后我做了brew install armadillo --with-hdf5
.由于这是一个链接问题(犰狳在错误的地方寻找libhdf5.101.dylib
(,我接下来做了brew link armadillo
.然后,如果您收到冲突的文件错误,只需执行brew link --overwrite armadillo
.祝你好运!
相关文章:
- 在这个函数中是有缺陷的,因为取消引用 null 是无效的,所以我想更改代码
- 无法使用犰狳运行编译的 cpp 代码,因为 dyld:库未加载
- 我的代码中是否有任何类型的错误,因为它没有给出正确的输出
- 加快一个长python代码的速度,因为只有一个块,所以速度很慢
- 无法编译代码,因为它已在 C++11 中弃用
- 在给定相同的输入的情况下,某些代码怎么可能花费更多时间来运行,这似乎只是因为它处于循环中?
- 为什么这段代码给出错误......'a'是指针到字符指针,应该存储's'的地址,因为s是指向数组的第一个元素的指针
- 我的 c++ 程序不断崩溃,因为我的代码很糟糕
- C Linux代码破坏Windows构建,因为缺少标头意味着功能不确定
- 因为一行不相关的代码,速度相差那么大
- 错误,因为"static" C++代码
- 试图理解得墨忒耳定律,因为它适用于我的代码
- 无法用C++编写相同的 Java 代码"cannot initialize class member here"因为错误
- 我的代码可能崩溃了,因为'class'与 C 不兼容?
- 为什么我的代码会因为函数内部有显式构造函数的静态对象的声明而崩溃
- 我不明白为什么编译代码片段的第二个版本。AFAIK 它不应该,因为 §10.3/2
- 为什么我在代码块中遇到编译错误,因为我使用的变量超出了范围?
- 使用符号c++库:如何在objective C中打印矩阵输出描述?因为我加了两个矩阵.代码如下,谢谢
- 以下代码有什么问题,因为我收到未定义的"w"?
- 我的代码有问题,因为我无法弄清楚为什么会收到错误。这是代码: