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

installation latest Caffe on mac OS X 10.10.4 #2956

Closed
chunfuchen opened this issue Aug 21, 2015 · 6 comments
Closed

installation latest Caffe on mac OS X 10.10.4 #2956

chunfuchen opened this issue Aug 21, 2015 · 6 comments

Comments

@chunfuchen
Copy link

Hi, all,
I got the compilation error no matter use Cmake or Make. I follow the installation guide on Caffe webpage and install all dependency libraries via homebrew. I find that I can work well for previous version. Nonetheless, when I pull the updates from Caffe repo, I can not build Caffe.
I got the following error message:
Does anyone get the same issue? Thanks.

Undefined symbols for architecture x86_64:
"leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, leveldb::DB*)", referenced from:
caffe::db::LevelDB::Open(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, caffe::db::Mode) in db_leveldb.cpp.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[2]: *
* [lib/libcaffe.dylib] Error 1
make[1]: *** [src/caffe/CMakeFiles/caffe.dir/all] Error 2

I do this command to check my configuration:

cmake -DCUDNN_INCLUDE=/usr/local/cuda/cudnn -DCUDNN_LIBRARY=/usr/local/cuda/cudnn/libcudnn.6.5.dylib ../

It returns:
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- system
-- thread
-- Found gflags (include: /usr/local/include, library: /usr/local/lib/libgflags.dylib)
-- Found glog (include: /usr/local/include, library: /usr/local/lib/libglog.dylib)
-- Found PROTOBUF Compiler: /opt/protobuf/bin/protoc
-- Found lmdb (include: /usr/local/include, library: /usr/local/lib/liblmdb.dylib)
-- Found LevelDB (include: /Users/cfchen/anaconda/include, library: /Users/cfchen/anaconda/lib/libleveldb.dylib)
-- Found Snappy (include: /Users/cfchen/anaconda/include, library: /Users/cfchen/anaconda/lib/libsnappy.dylib)
-- CUDA detected: 7.0
-- Found cuDNN (include: /usr/local/cuda/cudnn, library: /usr/local/cuda/cudnn/libcudnn.6.5.dylib)
-- Added CUDA NVCC flags for: sm_30
-- Cuda + Boost 1.55: Applying noinline work around
-- OpenCV found (/usr/local/share/OpenCV)
-- Found vecLib as part of Accelerate.framework
-- NumPy ver. 1.9.2 found (include: /Users/cfchen/anaconda/lib/python2.7/site-packages/numpy/core/include)
-- Boost version: 1.55.0
-- Found the following Boost libraries:
-- python
-- Found Doxygen: /usr/local/bin/doxygen (found version "1.8.10")
-- Detected Doxygen OUTPUT_DIRECTORY: ./doxygen/
-- ******************* Caffe Configuration Summary *******************
-- General:
-- Version : (Caffe doesn't declare its version in headers)
-- Git : rc2-465-g6232233
-- System : Darwin
-- C++ compiler : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
-- Debug CXX flags : -g -fPIC -Wall -Wno-sign-compare -Wno-uninitialized
-- Build type : Release
-- BUILD_SHARED_LIBS : ON
-- BUILD_python : ON
-- BUILD_matlab : OFF
-- BUILD_docs : ON
-- CPU_ONLY : OFF
-- Dependencies:
-- BLAS : Yes (vecLib)
-- Boost : Yes (ver. 1.55)
-- glog : Yes
-- gflags : Yes
-- protobuf : Yes (ver. 3.0.0)
-- lmdb : Yes (ver. 0.9.14)
-- Snappy : Yes (ver. 1.1.1)
-- LevelDB : Yes (ver. 1.15)
-- OpenCV : Yes (ver. 2.4.12)
-- CUDA : Yes (ver. 7.0)
-- NVIDIA CUDA:
-- Target GPU(s) : Auto
-- GPU arch(s) : sm_30
-- cuDNN : Yes
-- Python:
-- Interpreter : /Users/cfchen/anaconda/bin/python2.7 (ver. 2.7.10)
-- Libraries : /usr/lib/libpython2.7.dylib (ver 2.7.6)
-- NumPy : /Users/cfchen/anaconda/lib/python2.7/site-packages/numpy/core/include (ver 1.9.2)
-- Documentaion:
-- Doxygen : /usr/local/bin/doxygen (1.8.10)
-- config_file : /Users/cfchen/Developer/bvlc_caffe/.Doxyfile
-- Install:
-- Install path : /Users/cfchen/Developer/bvlc_caffe/build/install
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/cfchen/Developer/bvlc_caffe/build

@odellus
Copy link

odellus commented Aug 21, 2015

@chunfuchen You might want to try adding -shared to CMAKE_EXE_LINKER_FLAGS so you can link the files you have successfully compiled against the shared library libleveldb.dynlib. That seems to be the problem to me. To clear up what is happening you should read this.

@chunfuchen
Copy link
Author

@odellus Thanks your comments, after I add -shared to CMAKE_EXE_LINKER_FLAGS, it does not work. Afterward, I found that cmake will try to link my leveldb, snappy, hdf5, shared libraries to the one in my anaconda python env.... After I uninstall those libraries in my anaconda, it works well; however, I think I should resolve the search path in cmake.

Update:
After changing the order of library path in Makefile.config, everything works well.
Put the homebrew libraries path in front of PYTHON_LIB

INCLUDE_DIRS := /usr/local/include $(PYTHON_INCLUDE)
LIBRARY_DIRS := /usr/local/lib /usr/lib $(PYTHON_LIB)

@odellus
Copy link

odellus commented Aug 21, 2015

@chunfuchen Glad you could get it working. 👍

@robinlkm
Copy link

Hey, I got the similar problem with yours.
But the solution list above did not work.
Do you have any some advice?

"leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, leveldb::DB*)", referenced from:
caffe::db::LevelDB::Open(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&, caffe::db::Mode) in db_leveldb.o
"google::protobuf::MessageLite::SerializeToString(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator >
) const", referenced from:
caffe::Net::Forward(std::__1::basic_string<char, std::__1::char_traits, std::_1::allocator > const&, float) in net.o
caffe::Net::Forward(std::__1::basic_string<char, std::__1::char_traits, std::_1::allocator > const&, double) in net.o
"google::protobuf::DescriptorPool::FindFileByName(std::__1::basic_string<char, std::__1::char_traits, std::__1::allocator > const&) const", referenced from:
caffe::protobuf_AssignDesc_caffe_2eproto() in caffe.pb.o
"google::protobuf::Message::SerializeToOstream(std::__1::basic_ostream<char, std::__1::char_traits >) const", referenced from:
caffe::WriteProtoToBinaryFile(google::protobuf::Message const&, char const
) in io.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: *** [.build_release/lib/libcaffe.so] Error 1

@michaelbrundage
Copy link

I got this same error with current Caffe, CUDA, MacOS, brew, etc. I followed all the instructions at http://caffe.berkeleyvision.org/installation.html#compilation
The suggested workaround above -- reordering the directories in Makefile.config -- had no impact.

LD -o .build_release/lib/libcaffe.so.1.0.0-rc3
clang: warning: argument unused during compilation: '-pthread'
Undefined symbols for architecture x86_64:
  "leveldb::DB::Open(leveldb::Options const&, std::__1::basic_string, std::__1::allocator > const&, leveldb::DB**)", referenced from:
      caffe::db::LevelDB::Open(std::__1::basic_string, std::__1::allocator > const&, caffe::db::Mode) in db_leveldb.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: *** [.build_release/lib/libcaffe.so.1.0.0-rc3] Error 1
make: *** Waiting for unfinished jobs....

@michaelbrundage
Copy link

I finally found and fixed the error. For me, the problem wasn't with protobuf but with leveldb:

> otool -L /usr/local/Cellar/protobuf/2.6.1/lib/libprotoc.9.dylib
...
    /usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.1.0)
...

> otool -L /usr/local/lib/libleveldb.dylib
...
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
...

The solution then was

brew uninstall leveldb && brew install leveldb --c++11

FWIW, I'm seeing a lot of open and closed caffe issues that seem to be related to this general problem (some dependencies installed with libstdc++ instead of libc++). Maybe there could be a more general solution, such as scanning first to make sure all the dependencies are correct.

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

4 participants