tensorflow: Building TensorFlow failed
Issue
I’m trying to build the .so file using bazel
bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a
Getting an error:
tensorflow/core/BUILD:2306:1: C++ compilation of rule '//tensorflow/core:protos_all_proto_cc_impl' failed (Exit 1)
In file included from bazel-out/armeabi-v7a-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.cc:4:
In file included from bazel-out/armeabi-v7a-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:9:
In file included from external/protobuf_archive/src/google/protobuf/stubs/common.h:52:
In file included from external/protobuf_archive/src/google/protobuf/stubs/mutex.h:33:
In file included from external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/mutex:35:
external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/bits/c++0x_warning.h:32:2: error: This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
#error This file requires compiler and library support for the \
^
In file included from bazel-out/armeabi-v7a-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.cc:4:
In file included from bazel-out/armeabi-v7a-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:9:
In file included from external/protobuf_archive/src/google/protobuf/stubs/common.h:52:
external/protobuf_archive/src/google/protobuf/stubs/mutex.h:58:8: error: no type named 'mutex' in namespace 'std'
std::mutex mu_;
In file included from bazel-out/armeabi-v7a-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.cc:4:
In file included from bazel-out/armeabi-v7a-opt/genfiles/tensorflow/core/framework/tensor_shape.pb.h:9:
In file included from external/protobuf_archive/src/google/protobuf/stubs/common.h:53:
external/protobuf_archive/src/google/protobuf/stubs/callback.h:346:25: error: no type named 'remove_reference' in namespace 'std'
typedef typename std::remove_reference<T>::type base_type;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:346:41: error: expected member name or ';' after declaration specifiers
typedef typename std::remove_reference<T>::type base_type;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:347:17: error: unknown type name 'base_type'
typedef const base_type& type;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:401:17: error: no type named 'remove_reference' in namespace 'std'
typename std::remove_reference<P1>::type p1_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:401:33: error: expected member name or ';' after declaration specifiers
typename std::remove_reference<P1>::type p1_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:402:17: error: no type named 'remove_reference' in namespace 'std'
typename std::remove_reference<P2>::type p2_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:402:33: error: expected member name or ';' after declaration specifiers
typename std::remove_reference<P2>::type p2_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:403:17: error: no type named 'remove_reference' in namespace 'std'
typename std::remove_reference<P3>::type p3_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:403:33: error: expected member name or ';' after declaration specifiers
typename std::remove_reference<P3>::type p3_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:404:17: error: no type named 'remove_reference' in namespace 'std'
typename std::remove_reference<P4>::type p4_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:404:33: error: expected member name or ';' after declaration specifiers
typename std::remove_reference<P4>::type p4_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:405:17: error: no type named 'remove_reference' in namespace 'std'
typename std::remove_reference<P5>::type p5_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:405:33: error: expected member name or ';' after declaration specifiers
typename std::remove_reference<P5>::type p5_;
external/protobuf_archive/src/google/protobuf/stubs/callback.h:383:9: error: member initializer 'p1_' does not name a non-static data member or base class
p1_(p1),
external/protobuf_archive/src/google/protobuf/stubs/callback.h:384:9: error: member initializer 'p2_' does not name a non-static data member or base class
p2_(p2),
external/protobuf_archive/src/google/protobuf/stubs/callback.h:385:9: error: member initializer 'p3_' does not name a non-static data member or base class
p3_(p3),
external/protobuf_archive/src/google/protobuf/stubs/callback.h:386:9: error: member initializer 'p4_' does not name a non-static data member or base class
p4_(p4)
System information
OS: macOS High Sierra 10.13.3
bazel:
Build label: 0.15.0-homebrew Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar Build time: Tue Jun 26 12:42:27 2018 (1530016947) Build timestamp: 1530016947 Build timestamp as int: 1530016947
ndk: android-ndk-r16b
I looked similar problems, like #3924 or #17046, but unfortunately did not find a solution for himself.
Thank you in advance.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 16 (1 by maintainers)
Issue solved, just building with the --cxxopt=-std=c++11 flag
That works, thanks a lot. Should be updated here: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/android ?