我有一组使用Armadillo和BLAS / LAPACK的mex文件,可以在Windows上使用以下文件进行编译:
srcFolder = pwd;
outputFolder = 'some/other/folder/';
blaslib = fullfile(matlabroot, 'extern', 'lib', computer('arch'), 'microsoft', 'libmwblas.lib');
lapacklib = fullfile(matlabroot, 'extern', 'lib', computer('arch'), 'microsoft', 'libmwlapack.lib');
flags = {'-O', '-outdir', outputFolder};
mex(flags{:}, fullfile(srcFolder, 'filter_uni.cpp'), blaslib, lapacklib);
当我在linux上尝试此操作时,链接器似乎找不到我提供的.so文件:
blaslib = fullfile(matlabroot, 'bin', computer('arch'), 'libmwblas.so')
lapacklib = fullfile(matlabroot, 'bin', computer('arch'), 'libmwlapack.so')
mex(flags{:}, fullfile(srcFolder, 'filter_uni.cpp'), blaslib, lapacklib, '-v');
部分输出:
...
/usr/bin/g++ -pthread -Wl,--no-undefined -shared -O -Wl,--version-script,"/usr/local/Matlab/R2018a/extern/lib
/glnxa64/c_exportsmexfileversion.map" /tmp/mex_8538435756757296_40383/filter_uni.o /tmp/mex_8538435756757296_4
0383/cpp_mexapi_version.o /usr/local/Matlab/R2018a/bin/glnxa64/libmwblas.so /usr/local/Matlab/R2018a/bin/gln
xa64/libmwlapack.so -Wl,--as-needed -Wl,-rpath-link,/usr/local/Matlab/R2018a/bin/glnxa64 -L"/usr/local/Matlab
/R2018a/bin/glnxa64" -Wl,-rpath-link,/usr/local/Matlab/R2018a/extern/bin/glnxa64 -L"/usr/local/Matlab/R2018a/e
xtern/bin/glnxa64" -lMatlabDataArray -lmx -lmex -lmat -lm -lstdc++ -o /home/dkelley/MFSS/+mfss_mex/filter_uni.
mexa64
Error using mex
/tmp/mex_8538435756757296_40383/filter_uni.o: In function `filter_uni_mex(arma::Mat<double>,
arma::Cube<double>, arma::Mat<double>, arma::Cube<double>, arma::Cube<double>, arma::Mat<double>,
arma::Cube<double>, arma::Cube<double>, arma::Mat<double>, arma::Mat<double>, arma::Mat<double>,
arma::Mat<double>, _Tau)':
filter_uni.cpp:(.text+0x23db): undefined reference to `ddot'
filter_uni.cpp:(.text+0x3310): undefined reference to `dgemv'
filter_uni.cpp:(.text+0x5fca): undefined reference to `ddot'
filter_uni.cpp:(.text+0x66a1): undefined reference to `dgemv'
filter_uni.cpp:(.text+0x6780): undefined reference to `dgemv'
filter_uni.cpp:(.text+0x6b01): undefined reference to `dgemv'
filter_uni.cpp:(.text+0x6be0): undefined reference to `dgemv'
...
是否有其他方法指定应在Linux上使用的.so文件?