无效的mex文件libarmadillo无法打开共享对象文件 [英] Invalid mex-file, libarmadillo, cannot open shared object file
问题描述
我知道有很多关于该主题的帖子,这可能是重复的,但我不这么认为.我的配置是:Matlab R2014b,clang 3.4,Ubuntu 14.04,armadillo-4.600.4.
I know there are a lot of posts about the topic, this might be a duplicate, but I don't think so. My config is: Matlab R2014b, clang 3.4, Ubuntu 14.04, armadillo-4.600.4.
我有一个Armadillo的本地安装(不是系统安装的,所以需要手动连接/链接),在Matlab之外运行时效果很好. 我正在尝试使用Matlab中的Armadillo运行Mex文件.使用以下命令可以将其编译良好(简称为截断):
I have a local install (not system-wise, so including/linking manually) of Armadillo that works fine when outside of Matlab. I'm trying to run a Mex file using Armadillo from Matlab. It compiles fine using the command (truncated for short):
mex -compatibleArrayDims -outdir +mx -L/home/john/.local/arma/lib -larmadillo -I/home/john/.local/arma/include test_arma.cpp
问题是当我尝试运行它时,出现此错误:
Problem is when I try to run it I get this error:
Error using mx.test_arma
Invalid MEX-file '/path/to/+mx/test_arma.mexa64': libarmadillo.so.4: cannot open shared object file: No such file or directory
从启动Matlab的外壳程序中回显的环境变量LD_LIBRARY_PATH
包含/home/john/.local/arma/lib
(其中libarmadillo.so
在其中),我还使用setenv('LD_LIBRARY_PATH',...)
在Matlab中手动添加了此路径.有什么我想念的吗?
The environment variable LD_LIBRARY_PATH
echoed from the shell that started Matlab contains /home/john/.local/arma/lib
(where libarmadillo.so
is), and I also manually added this path within Matlab using setenv('LD_LIBRARY_PATH',...)
. Is there something I'm missing?
推荐答案
所以我找到了如何运行的方法.现在是段错误了:/而且我相当有信心这不是代码本身,因为我可以在Matlab之外编译和运行完全相同的代码.我将尝试找出问题所在,如果有问题,我将稍后在此发布我的冒险经历.
So I found out how to run it. Now it's segfaulting :/ And I'm fairly confident it's not the code itself, because I can compile and run the exact same code outside Matlab. I'll try to find out what's wrong, and if it's relevant, I'll post my adventures here later on.
针对运行问题; Matlab似乎使用变量LD_RUN_PATH
在运行时加载共享库.在我的情况下,使用setenv
将我的路径... /.local/arma/lib
附加到LD_RUN_PATH
可以达到目的.为您的评论/答案加油!
For the running problem; it seems that Matlab uses the variable LD_RUN_PATH
for loading shared libraries at runtime. Appending my path ... /.local/arma/lib
to LD_RUN_PATH
using setenv
did the trick in my case. Cheers for your comments/answers!
更新:我终于解决了这个问题,这是由于Matlab的BLAS/LAPACK库之间存在预期的字长不匹配(32/64位,即int32_t
与int64_t
)和犰狳的电话.我在此处发布了两种解决方案.
Update: I finally solved this, the problem was due to an expected word-size mismatch (32/64 bits, ie int32_t
vs. int64_t
) between Matlab's BLAS/LAPACK libraries and Armadillo's calls. There are two solutions that I posted here.
这篇关于无效的mex文件libarmadillo无法打开共享对象文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!