yan99033 / monodepth-cpp

Tensorflow C++ implementation for single-image depth estimation (Monodepth)
MIT License
105 stars 33 forks source link

make && make install for error: #7

Closed molyswu closed 5 years ago

molyswu commented 5 years ago

make && make install
libmonodepth.so: undefined reference to tensorflow::ReadBinaryProto(tensorflow::Env*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::MessageLite*)' libmonodepth.so: undefined reference totensorflow::TfCheckOpHelperOutOfLine[abi:cxx11](tensorflow::Status const&, char const*)' libmonodepth.so: undefined reference to `tensorflow::internal::CheckOpMessageBuilder::NewString[abi:cxx11]()' collect2: error: ld returned 1 exit status CMakeFiles/inference_monodepth.dir/build.make:114: recipe for target 'inference_monodepth' failed make[2]: [inference_monodepth] Error 1 CMakeFiles/Makefile2:104: recipe for target 'CMakeFiles/inference_monodepth.dir/all' failed make[1]: [CMakeFiles/inference_monodepth.dir/all] Error 2 Makefile:127: recipe for target 'all' failed

Thanks!

yan99033 commented 5 years ago

It seems that you don't have the right Protobuf version for your Tensorflow library. What versions of the Tensorflow and Protobuf you are using?

yan99033 commented 5 years ago

Please refer to the closed issues about compiling with the right Protobuf version.

molyswu commented 5 years ago

libmonodepth.so: undefined reference to tensorflow::ReadBinaryProto(tensorflow::Env*, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, google::protobuf::MessageLite*)' libmonodepth.so: undefined reference totensorflow::TfCheckOpHelperOutOfLine[abi:cxx11](tensorflow::Status const&, char const*)' libmonodepth.so: undefined reference to `tensorflow::internal::CheckOpMessageBuilder::NewString[abi:cxx11]()' collect2: error: ld returned 1 exit status CMakeFiles/inference_monodepth.dir/build.make:114: recipe for target 'inference_monodepth' failed

molyswu commented 5 years ago

my Protobuf used 3.5.1

yan99033 commented 5 years ago

And which Tensorflow version you are using?

molyswu commented 5 years ago

Tensorflow v1.6.0

yan99033 commented 5 years ago

One thing I learnt after numerous successes and failures of building the Tensorflow-cpp , it should work if you follow the exact dependencies versions that are required, for example, Tensorflow v1.6.0 also requires GCC 4.8.0, Bazel 0.9.0, among others.

yan99033 commented 5 years ago

Hey, I faced the exact same error and here is what I found.

It turned out that there is an issue if your Tensorflow library was built with GCC-4.8 and linked to a c++11 project. Actually, it can be observed in the error message: it was the linking problem abi:cxx11

libmonodepth.so: undefined reference to tensorflow::TfCheckOpHelperOutOfLine[abi:cxx11](tensorflow::Status const&, char const*)

For more info about the error, read this

All you need to do is to rebuild the Tensorflow library using GCC-5, which is how I solved the problem. Here are the steps to perform a clean rebuild:

  1. cd /path/to/tensorflow
  2. bazel clean --expunge
  3. ./configure [be sure to specify the correct GCC version. To check the GCC version, do /usr/bin/gcc --version; use /usr/bin/gcc-5 directly if you have it]
  4. follow the rest of the steps in the build instructions
yan99033 commented 5 years ago

In case someone faces the same problem, you can also add --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" as one of the bazel build options for better ABI compatibility between different GCC versions.

image

For more information, read this

molyswu commented 5 years ago

Yes ,I add --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" ,ok.