Error when Linking CXX executable caffe

268 views
Skip to first unread message

Jiaxu Zhu

unread,
Nov 4, 2015, 2:25:23 AM11/4/15
to Caffe Users
I met some errors when compiling caffe

CMakeFiles/caffe.bin.dir/caffe.cpp.o: In function `std::string* google::MakeCheckOpString<cudaError, cudaError>(cudaError const&, cudaError const&, char const*)':
caffe.cpp:(.text._ZN6google17MakeCheckOpStringI9cudaErrorS1_EEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringI9cudaErrorS1_EEPSsRKT_RKT0_PKc]+0x50): undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
CMakeFiles/caffe.bin.dir/caffe.cpp.o: In function `std::string* google::MakeCheckOpString<unsigned long, int>(unsigned long const&, int const&, char const*)':
caffe.cpp:(.text._ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc]+0x50): undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
CMakeFiles/caffe.bin.dir/caffe.cpp.o: In function `main':
caffe.cpp:(.text.startup+0x50): undefined reference to `google::SetUsageMessage(std::string const&)'
../lib/libcaffe.so: undefined reference to `leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)'
../lib/libcaffe.so: undefined reference to `leveldb::Status::ToString() const'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/caffe.bin.dir/build.make:120: recipe for target 'tools/caffe' failed
make[2]: *** [tools/caffe] Error 1
CMakeFiles/Makefile2:406: recipe for target 'tools/CMakeFiles/caffe.bin.dir/all' failed
make[1]: *** [tools/CMakeFiles/caffe.bin.dir/all] Error 2
Makefile:116: recipe for target 'all' failed
make: *** [all] Error 2

This error is kind of rare and I cannot solve it bymyself
I have all dependencies installed and the platform is Ubuntu 15.10 (since my pc motherboard is Z170) 

Thanks!

Piotr Koncewicz

unread,
Sep 29, 2016, 6:38:37 PM9/29/16
to Caffe Users
Well I had the same trouble :) The solution is:
change your gcc and c++ to 4.9

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++

sudo update-alternatives --config gcc sudo update-alternatives --config g++

download other leveldb version, like this https://github.com/chirino/leveldb (if you compile it before changing gcc, the problem will still appear, but shorter, without leveldb errors)
clean and recompile protobuf, glog, leveldb and gflags
Goodluck!
Reply all
Reply to author
Forward
0 new messages