How to solve Caffe matlab invalid mex file

After Install Caffe http://caffe.berkeleyvision.org/ on my Linux Machine Linux Mint based on Ubuntu 14.04
I am trying to use matlab interface mex file. Here is what I got

>>matcaffe_demo

Invalid MEX-file
'/home/Feature/caffe-master/matlab/caffe/caffe.mexa64':
/usr/local/lib/libopencv_highgui.so.2.4: undefined symbol:
_ZNK9QCheckBox15minimumSizeHintEv
Error in matcaffe_init (line 19)
if caffe('is_initialized') == 0
Error in matcaffe_demo (line 53)
matcaffe_init();

What I did to solve this problem was to check ldd between matlab and linux 
in Linux Command Line

ldd matlab/caffe/caffe.mexa64

on Matlab

!ldd matlab/caffe/caffe.mexa64



There are many library of which when running mex file in Matlab points to matlab provided libraries (via symbolic links) instead of native library. so I change all of that by

ln -s   <lib.so name in native> <symbolic link lib.so name found on Matlab>

If the destination symbolic links are already exist, one must delete them before ln.

For example, two of those symbolic links are qtGui.so and qtCore.so. One may just 

 sudo rm /usr/local/MATLAB/R2012b/bin/glnxa64/libQtGui.so.4
 sudo ln -s /usr/lib/x86_64-linux-gnu/libQtGui.so.4 /usr/local/MATLAB/R2012b/bin/glnxa64/libQtGui.so.4
 sudo rm  /usr/local/MATLAB/R2012b/bin/glnxa64/libQtCore.so.4
sudo ln -s /usr/lib/x86_64-linux-gnu/libQtCore.so.4  /usr/local/MATLAB/R2012b/bin/glnxa64/libQtCore.so.4

The way around this is to launch matlab with

LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libQtCore.so:/usr/lib/x86_64-linux-gnu/libQtGui.so matlab






ความคิดเห็น

บทความที่ได้รับความนิยม