Invalid mex-file, libarmadillo, cannot open shared object file

筅森魡賤 提交于 2019-12-02 07:11:27

问题


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.

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

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?


回答1:


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.

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!

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.



来源:https://stackoverflow.com/questions/28408156/invalid-mex-file-libarmadillo-cannot-open-shared-object-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!