Linking stage issues with google protobuf #5640

Open
fbonnet08 opened this Issue May 24, 2017 · 3 comments

Comments

Projects
None yet
3 participants

Please use the caffe-users list for usage, installation, or modeling questions, or other requests for help.
Do not post such requests to Issues. Doing so interferes with the development of Caffe.

Please read the guidelines for contributing before submitting this issue.

Issue summary

I having some issues at compilation time, and it seems to fail at linking time at the same place in different systems. The neccessary software has been installed such as protobuf-dev, atlas and the like following the caffe instruction.

The summary of the error is given as follows:

[ 81%] Building CXX object src/caffe/CMakeFiles/caffe.dir/common.cpp.o [ 81%] Linking CXX shared library ../../lib/libcaffe.so [ 81%] Built target caffe Scanning dependencies of target compute_image_mean [ 81%] Building CXX object tools/CMakeFiles/compute_image_mean.dir/compute_image_mean.cpp.o [ 83%] Linking CXX executable compute_image_mean CMakeFiles/compute_image_mean.dir/compute_image_mean.cpp.o: In functionstd::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)':
compute_image_mean.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x50): undefined reference to google::base::CheckOpMessageBuilder::NewString()' CMakeFiles/compute_image_mean.dir/compute_image_mean.cpp.o: In functionstd::string* google::MakeCheckOpString<unsigned long, int>(unsigned long const&, int const&, char const*)':
compute_image_mean.cpp:(.text._ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc[ZN6google17MakeCheckOpStringImiEEPSsRKT_RKT0_PKc]+0x50): undefined reference to google::base::CheckOpMessageBuilder::NewString()' CMakeFiles/compute_image_mean.dir/compute_image_mean.cpp.o: In functionmain':
compute_image_mean.cpp:(.text.startup+0x172): undefined reference to google::SetUsageMessage(std::string const&)' compute_image_mean.cpp:(.text.startup+0x2ab): undefined reference togoogle::protobuf::MessageLite::ParseFromString(std::string const&)'
compute_image_mean.cpp:(.text.startup+0x499): undefined reference to google::protobuf::MessageLite::ParseFromString(std::string const&)' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::Message::InitializationErrorString() const'
../lib/libcaffe.so.1.0.0: undefined reference to google::protobuf::internal::WireFormatLite::WriteStringMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream*)' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::io::CodedOutputStream::WriteStringWithSizeToArray(std::string const&, unsigned char*)'
../lib/libcaffe.so.1.0.0: undefined reference to google::protobuf::internal::WireFormatLite::ReadString(google::protobuf::io::CodedInputStream*, std::string*)' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::Message::GetTypeName() const'
../lib/libcaffe.so.1.0.0: undefined reference to google::protobuf::Message::DebugString() const' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::internal::empty_string
'
../lib/libcaffe.so.1.0.0: undefined reference to google::protobuf::internal::NameOfEnum(google::protobuf::EnumDescriptor const*, int)' ../lib/libcaffe.so.1.0.0: undefined reference tocv::imread(std::string const&, int)'
../lib/libcaffe.so.1.0.0: undefined reference to google::protobuf::DescriptorPool::FindFileByName(std::string const&) const' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::internal::WireFormatLite::ReadBytes(google::protobuf::io::CodedInputStream*, std::string*)'
../lib/libcaffe.so.1.0.0: undefined reference to google::protobuf::internal::StringTypeHandlerBase::Delete(std::string*)' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::MessageFactory::InternalRegisterGeneratedFile(char const*, void ()(std::string const&))'
../lib/libcaffe.so.1.0.0: undefined reference to leveldb::DB::Open(leveldb::Options const&, std::string const&, leveldb::DB**)' ../lib/libcaffe.so.1.0.0: undefined reference tocv::imencode(std::string const&, cv::_InputArray const&, std::vector<unsigned char, std::allocator >&, std::vector<int, std::allocator > const&)'
../lib/libcaffe.so.1.0.0: undefined reference to google::protobuf::internal::StringTypeHandlerBase::New()' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::internal::WireFormatLite::WriteBytesMaybeAliased(int, std::string const&, google::protobuf::io::CodedOutputStream
)'
../lib/libcaffe.so.1.0.0: undefined reference to leveldb::Status::ToString() const' ../lib/libcaffe.so.1.0.0: undefined reference togoogle::protobuf::internal::WireFormatLite::WriteString(int, std::string const&, google::protobuf::io::CodedOutputStream*)'
collect2: error: ld returned 1 exit status
tools/CMakeFiles/compute_image_mean.dir/build.make:134: recipe for target 'tools/compute_image_mean' failed
make[2]: *** [tools/compute_image_mean] Error 1
CMakeFiles/Makefile2:467: recipe for target 'tools/CMakeFiles/compute_image_mean.dir/all' failed
make[1]: *** [tools/CMakeFiles/compute_image_mean.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
`

Steps to reproduce

If you are having difficulty building Caffe or training a model, please ask the caffe-users mailing list. If you are reporting a build error that seems to be due to a bug in Caffe, please attach your build configuration (either Makefile.config or CMakeCache.txt) and the output of the make (or cmake) command.

Your system configuration

Operating system: linux-x86_64
Compiler: gnu chain tool gcc,g++, gfortran--> 4.9.3
CUDA version: cuda-8.0 driver version 375.39
CUDNN version (if applicable): v5
BLAS: atlas, built in blas
Python or MATLAB version (for pycaffe and matcaffe respectively): python3

ou525 commented Jul 1, 2017

i I encountered the same problem, how can you solve?

akorzh commented Jul 10, 2017

same problem for me.
Looks like the problem is that i had gcc 7.1.1 in my system and system protobuf was built with that one.
But CUDA is not supporting gcc >5, so using devtoolset i installed gcc 5.3.1 and used this one to build caffe, but it wont link with protobuf....
And building with gcc 7.1.1 works fine and links to protobuf but CPU only version as CUDA wont compile.
So i am building protobuf from sources using gcc 5.3.1 so it would link to caffe....

hope it helps, folks

akorzh commented Jul 10, 2017

actually wasnt anough. i had recompiled both protobuf (3.2.0) and glog(HEAD) from git with -fPIC ( ./configure --enable-shared --with-pic). NB: protobuf 3.3.0 gave errors for some goooglish reasons.
Also with caffe, edited makefile: removed protobuf and glog from LIBRARIES and added as static to LDFLAGS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment