我有一个mex
使用OpenCV
我正在尝试使用的功能。编译似乎有效,但是当我尝试在其中调用该函数时MATLAB
出现此错误:
Invalid MEX-file '/path/to/project/mexfunction.mexa64': libopencv_legacy.so.2.4: cannot open shared object file: No such file or directory
我的OpenCV 2.4.5
安装位于/nwdata/username/
(我使用他们文档中的 OpenCV 推荐设置从头开始编译自己)。我使用这个函数与 mex 一起编译:
function cvmex(mexfile)
OCV_INC_DIR='/nwdata/username/include/opencv';·
OCV2_INC_DIR='/nwdata/username/include';·
OCV_LIB_DIR ='/nwdata/username/lib';·
mex(mexfile,'-g','-v',['-I',OCV2_INC_DIR],['-I',OCV_INC_DIR],['-L',OCV_LIB_DIR],'DUSE_DOUBLE',...
'-lopencv_legacy','-lopencv_imgproc','-lopencv_core','-lopencv_contrib','-lopencv_ml',...
'-lopencv_objdetect','-lopencv_calib3d','-lopencv_flann','-lopencv_features2d',...
'-lopencv_video','-lopencv_gpu');
end
当我编译时,我没有收到任何错误。然后我检查了库的依赖项正在使用什么ldd mexfunction.mexa64
。这是相关的行:
libopencv_legacy.so.2.4 => /nwdata/username/lib/libopencv_legacy.so.2.4 (0x00002ad6a2123000)
好的,所以看起来没问题。该文件肯定存在:
[username@machine:/nwdata/username/lib]
$ ls -l libopencv_legacy*
lrwxrwxrwx 1 username REDACTED 25 Jul 15 15:07 libopencv_legacy.so -> libopencv_legacy.so.2.4.5
lrwxrwxrwx 1 username REDACTED 25 Jul 15 15:07 libopencv_legacy.so.2.4 -> libopencv_legacy.so.2.4.5
-rwxr-xr-x 1 username REDACTED 1303944 Jun 17 15:37 libopencv_legacy.so.2.4.5
[username@machine:/nwdata/username/lib]
$ file libopencv_legacy.so*
libopencv_legacy.so: symbolic link to `libopencv_legacy.so.2.4.5'
libopencv_legacy.so.2.4: symbolic link to `libopencv_legacy.so.2.4.5'
libopencv_legacy.so.2.4.5: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, not stripped
在 Linux 上运行:
Linux machine@redacted 2.6.43.8-1.fc15.x86_64 #1 SMP Mon Jun 4 20:33:44 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
MATLAB R2011b, and g++ 4.6.3.
这似乎很奇怪。有任何想法吗?这台机器是集群的一部分,所以我没有 root 访问权限或任何东西。