Reputation: 7962
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?
Upvotes: 2
Views: 3229
Reputation: 7962
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.
Upvotes: 2