Hi, I am having issues with running 'make matcaffe'. It's giving me 'undefined symbols for architecture' errors. My system:
Mac OS X 10.11.3 (freshly installed)
Xcode 7
OpenCV 3 brew install opencv3
Protobuf brew install --build-from-source --with-python -vd protobuf
Matlab 2015b
make all make test make runtest all completed without errors, after realizing OS X 10.11 uses system integrity. Fixed this by running:
install_name_tool -add_rpath /usr/local/cuda/lib .build_release/tools/caffe
install_name_tool -add_rpath /usr/local/cuda/lib .build_release/test/test_all.testbin
install_name_tool -add_rpath /usr/local/cuda/lib .build_release/lib/libcaffe.so
I did this to point Matlab to Xcode 7: Link, and changed any reference to older versions of OS X in mexopts.sh to 10.11.
I think protobuf is installed correctly and included in /usr/local/include and /usr/local/lib. I was less sure about OpenCV 3, (since I installed OpenCV 2 as well) but removing any references to OpenCV and reinstalling 3 did not change anything.
In my Makefile.config I have this:
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/local/opt/opencv3/include
LIBRARY_DIRS := $(PYTHON_LIB) /Applications/MATLAB_R2015b.app/bin/maci64 /usr/local/lib /usr/lib /usr/local/opt/opencv3/lib
I could not find anything similar, can anybody help?
This is the output after running make matcaffe:
MEX matlab/+caffe/private/caffe_.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.
Undefined symbols for architecture x86_64:
"cv::String::deallocate()", referenced from:
caffe::WindowDataLayer
caffe::WindowDataLayer
caffe::ReadImageToCVMat(std::__1::basic_string
caffe::ReadImageToDatum(std::__1::basic_string
"cv::String::allocate(unsigned long)", referenced from:
caffe::WindowDataLayer
caffe::WindowDataLayer
caffe::ReadImageToCVMat(std::__1::basic_string
caffe::ReadImageToDatum(std::__1::basic_string
"google::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::__1::basic_string
caffe::Datum::SerializeWithCachedSizesToArray(unsigned char_) const in libcaffe.a(caffe.pb.o)
caffe::FillerParameter::SerializeWithCachedSizesToArray(unsigned char_) const in libcaffe.a(caffe.pb.o)
caffe::NetParameter::SerializeWithCachedSizesToArray(unsigned char_) const in libcaffe.a(caffe.pb.o)
caffe::SolverParameter::SerializeWithCachedSizesToArray(unsigned char_) const in libcaffe.a(caffe.pb.o)
caffe::SolverState::SerializeWithCachedSizesToArray(unsigned char_) const in libcaffe.a(caffe.pb.o)
caffe::NetState::SerializeWithCachedSizesToArray(unsigned char_) const in libcaffe.a(caffe.pb.o)
caffe::NetStateRule::SerializeWithCachedSizesToArray(unsigned char_) const in libcaffe.a(caffe.pb.o)
...
"google::protobuf::internal::empty_string_", referenced from:
caffe::Datum::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::Datum::MergeFrom(caffe::Datum const&) in libcaffe.a(caffe.pb.o)
caffe::Datum::~Datum() in libcaffe.a(caffe.pb.o)
caffe::Datum::SharedDtor() in libcaffe.a(caffe.pb.o)
caffe::Datum::Clear() in libcaffe.a(caffe.pb.o)
caffe::Datum::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream_) in libcaffe.a(caffe.pb.o)
caffe::NetParameter::SharedCtor() in libcaffe.a(caffe.pb.o)
...
"google::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::__1::basic_string
caffe::Datum::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
"google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::__1::basic_string
caffe::FillerParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
caffe::NetParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
caffe::SolverParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
caffe::SolverState::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
caffe::ParamSpec::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
caffe::LayerParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
caffe::TransformationParameter::SerializeWithCachedSizes(google::protobuf::io::CodedOutputStream_) const in libcaffe.a(caffe.pb.o)
...
"google::protobuf::internal::InitEmptyString()", referenced from:
caffe::Datum::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::FillerParameter::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::NetParameter::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::SolverParameter::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::SolverState::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::NetState::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::NetStateRule::SharedCtor() in libcaffe.a(caffe.pb.o)
...
"google::protobuf::internal::empty_string_once_init_", referenced from:
caffe::Datum::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::FillerParameter::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::NetParameter::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::SolverParameter::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::SolverState::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::NetState::SharedCtor() in libcaffe.a(caffe.pb.o)
caffe::NetStateRule::SharedCtor() in libcaffe.a(caffe.pb.o)
...
"google::protobuf::io::CodedInputStream::BytesUntilTotalBytesLimit() const", referenced from:
caffe::BlobProto::MergePartialFromCodedStream(google::protobuf::io::CodedInputStream_) in libcaffe.a(caffe.pb.o)
bool google::protobuf::internal::WireFormatLite::ReadPackedPrimitiveNoInline
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
mex: link of ' "matlab/+caffe/private/caffe_.mexmaci64"' failed.
make: *** [matlab/+caffe/private/caffe_.mexmaci64] Error 255
After installing everything over again I have it down to just the google::protobuf errors. Any ideas?
OK I fixed my own problem, for anyone having a similar issue, recent versions of Matlab ship their own opencv and protobuf etc. located in /Applications/MATLAB_R2015b/bin/maci64/
Deleting these fixed my problem (although it will probably break Matlabs computer vision).
I learned this thanks to this post: Link
Most helpful comment
OK I fixed my own problem, for anyone having a similar issue, recent versions of Matlab ship their own opencv and protobuf etc. located in /Applications/MATLAB_R2015b/bin/maci64/
Deleting these fixed my problem (although it will probably break Matlabs computer vision).
I learned this thanks to this post: Link