Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile matcaffe issue #2040

Closed
hermitman opened this issue Mar 5, 2015 · 3 comments
Closed

Compile matcaffe issue #2040

hermitman opened this issue Mar 5, 2015 · 3 comments

Comments

@hermitman
Copy link

I compiled caffe, and tried to compile matlab wrapper.

In the first try, I receive error as follows:

MEX matlab/caffe/matcaffe.cpp
Building with 'Xcode Clang++'.
Undefined symbols for architecture x86_64:
"_mxArrayToString", referenced from:
init(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
read_mean(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
_mexFunction in matcaffe.o
"_mxCreateCellArray_700", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateCellMatrix_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateDoubleScalar", referenced from:
init(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
is_initialized(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_init_key(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateNumericArray_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
read_mean(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateString", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxCreateStructArray_700", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxFree", referenced from:
init(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
_mexFunction in matcaffe.o
"_mxGetCell_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxGetDimensions_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxGetNumberOfElements", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxGetPr", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
read_mean(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxGetScalar", referenced from:
set_device(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxIsSingle", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxSetCell_700", referenced from:
forward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
backward(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
"_mxSetField_700", referenced from:
get_weights(int, mxArray_tag**, int, mxArray_tag const**) in matcaffe.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

make: *** [matlab/caffe/caffe.mexmaci64] Error 255

Following the tutorial mentioned in: #915, I did the following:

  1. I changed my mexopts.sh under ~/.matlab/R2014b, so everything is 10.8 now
  2. I modified Makefile.config to the following: LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /Applications/MATLAB_R2014b.app/bin/maci64 /usr/lib.

This time I got the following error:

MEX matlab/caffe/matcaffe.cpp
Warning: Legacy MEX infrastructure is provided for compatibility; it will be removed in a future version of MATLAB. For more information, consult the MEX release notes http://www.mathworks.com/help/matlab/release-notes.html.
clang: warning: no such sysroot directory: '-mmacosx-version-min=10.8'
In file included from matlab/caffe/matcaffe.cpp:6:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/sstream:174:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ostream:131:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:215:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:90:10: fatal error:
'wchar.h' file not found

include <wchar.h> // for mbstate_t

     ^

1 error generated.

mex: compile of ' "matlab/caffe/matcaffe.cpp"' failed.

make: *** [matlab/caffe/caffe.mexmaci64] Error 255

My system environment is as follows:

OSX10.10
MATLAB 2014b

Thanks for helping

@hermitman
Copy link
Author

Got rid of the above errors by using MATLAB 2013b, and add /usr/include into the Makefile.config INCLUDE_DIRS variables.

unfortunately the nightmare is not over. When I try to run the matlab demo, I receive:

Invalid MEX-file
'/Users/iamxuhao/Documents/research/caffe/matlab/caffe/caffe.mexmaci64':
dlopen(/Users/iamxuhao/Documents/research/caffe/matlab/caffe/caffe.mexmaci64,
6): Library not loaded: @rpath/libcurand.7.0.dylib
Referenced from:
/Users/iamxuhao/Documents/research/caffe/matlab/caffe/caffe.mexmaci64
Reason: image not found

@hermitman
Copy link
Author

Got the above fixed by setting a symbolic link from /usr/lib/cuda/libcurand.7.0.dylib to /Applications/MATLAB_R2013b.app/sys/os/maci64//libcurand.7.0.dylib.

Now, I am really stuck on this:

Invalid MEX-file
'/Users/iamxuhao/Documents/research/caffe/matlab/caffe/caffe.mexmaci64':
dlopen(/Users/iamxuhao/Documents/research/caffe/matlab/caffe/caffe.mexmaci64,
6): Library not loaded: /usr/local/lib/libtiff.5.dylib
Referenced from: /usr/local/lib/libopencv_highgui.2.4.dylib
Reason: Incompatible library version: libopencv_highgui.2.4.dylib
requires version 8.0.0 or later, but libtiff.5.dylib provides version
6.0.0

I think this error is raised because matlab uses a different library then the one used when I compile the mex. Unfortunately, I really don't know how to find out which version is the correct one.

I follow this caffe installation tutorial:
http://caffe.berkeleyvision.org/install_osx.html

so OpenCV is installed by homebrew as I setup the prerequisites.

running brew list opencv gives me the following:

/usr/local/Cellar/opencv/2.4.9/bin/opencv_createsamples
/usr/local/Cellar/opencv/2.4.9/bin/opencv_haartraining
/usr/local/Cellar/opencv/2.4.9/bin/opencv_performance
/usr/local/Cellar/opencv/2.4.9/bin/opencv_traincascade
/usr/local/Cellar/opencv/2.4.9/include/opencv/ (11 files)
/usr/local/Cellar/opencv/2.4.9/include/opencv2/ (150 files)
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_calib3d.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_contrib.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_core.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_features2d.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_flann.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_gpu.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_highgui.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_imgproc.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_legacy.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_ml.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_nonfree.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_objdetect.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_ocl.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_photo.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_stitching.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_superres.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_video.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/libopencv_videostab.2.4.9.dylib
/usr/local/Cellar/opencv/2.4.9/lib/pkgconfig/opencv.pc
/usr/local/Cellar/opencv/2.4.9/lib/python2.7/ (2 files)
/usr/local/Cellar/opencv/2.4.9/lib/ (37 other files)
/usr/local/Cellar/opencv/2.4.9/share/OpenCV/ (29 files)

checking /usr/local/lib, I found that there are two versions of opencv installed.

libopencv_highgui.2.4.9.dylib
libopencv_highgui.2.4.dylib

Based on the error message shown in the beginning of this ticket, matlab was looking for 2.4, but homebrew installed 2.4.9. But simply rename 2,4,9 to 2,4 will not satisfy matlab. Is there any other hacks to rescue the situation?

Thanks

@hermitman
Copy link
Author

fixed.....

solution is to add another symbolic link for libtoff.5.dylib

If anyone knows how to get matlab2014b work, please let me know the solution.

@n-zhang n-zhang closed this as completed Mar 12, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants