0

I used to compile successfully caffe with WITH_PYTHON_LAYER:=1 on Ubuntu 14.04. Then I switched to Ubuntu 16.04, using the same settings but different built-in software such as g++ 5.4 for 16.04 instead of g++ 4.8 for 14.04, I failed to compile caffe with python. Would you please give me some advice on this issue? The following is part of the error message I got

.build_release/lib/libcaffe.so: undefined reference to `std::overflow_error::overflow_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
.build_release/lib/libcaffe.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char, unsigned long) const'
.build_release/lib/libcaffe.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_construct(unsigned long, char)'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libboost_python.so: undefined reference to `std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::_M_construct(unsigned long, wchar_t)@GLIBCXX_3.4.21'
//usr/lib/x86_64-linux-gnu/libtbb.so.2: undefined reference to `std::out_of_range::out_of_range(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)@GLIBCXX_3.4.21'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libgflags.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const@GLIBCXX_3.4.21'
/usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libglog.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)@GLIBCXX_3.4.21'
.build_release/lib/libcaffe.so: undefined reference to `std::out_of_range::out_of_range(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
collect2: error: ld returned 1 exit status
Makefile:619: recipe for target '.build_release/tools/caffe.bin' failed
make: *** [.build_release/tools/caffe.bin] Error 1
pat
  • 763
  • 4
  • 12
Jake Ren
  • 13
  • 1
  • 6
  • Looks like you're not linking with the standard library. What is the build system for the library? – pat Nov 04 '16 at 04:50
  • I am not sure what build system it is. would you please specify what information I need to provide for you? – Jake Ren Nov 04 '16 at 04:53
  • How do you build it? Do you type "./configure" then "make", or do you have to say like "cmake .." first or something? – pat Nov 04 '16 at 04:55
  • Just follow the instruction from the Official Caffe Installation Instructions. I did not run ./configure. First, I edited the Makefile.config, which is used to choose options you want and config the path for lib and include_files. Second, I run make -j8 to compile the project – Jake Ren Nov 04 '16 at 04:58
  • Copy the whole g++ command line that is failing into your question – pat Nov 04 '16 at 05:17
  • Hi, may I have your email address or other communications to send you my Makefile.config? I think the problem is that the compiler version is too advanced or as you said, it is not linking with the standard library? I will send you information as much as you need. Thanks for your helps. – Jake Ren Nov 04 '16 at 15:30
  • http://stackoverflow.com/questions/33394934/converting-std-cxx11string-to-stdstring – pat Nov 04 '16 at 16:15
  • According to http://stackoverflow.com/questions/37004976/undefined-reference-to-processstd-cxx11basic-string-when-compiling-a?rq=1 the simplest solution is to just use gcc 4.8. – pat Nov 04 '16 at 16:18
  • If you really want to use the newer gcc, then make sure you build all the dependencies using the new library. That means if you already have a build directory, delete it and rebuild everything. – pat Nov 04 '16 at 16:19

1 Answers1

0

Following the official installation instruction with cmake solves this problem.

Steps to solution:
1. in your CAFFE/ directory run make clean
2. the follow in instruction of compile_caffe_with_cmake.

Jake Ren
  • 13
  • 1
  • 6