Closed molyswu closed 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?
Please refer to the closed issues about compiling with the right Protobuf version.
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 to
tensorflow::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
my Protobuf used 3.5.1
And which Tensorflow version you are using?
Tensorflow v1.6.0
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.
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:
/usr/bin/gcc --version
; use /usr/bin/gcc-5
directly if you have it]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.
For more information, read this
Yes ,I add --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" ,ok.
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 to
tensorflow::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' failedThanks!