snipsco / tensorflow-build

A set of scripts to (cross-)build the Tensorflow C lib for various architectures / OS
MIT License
178 stars 92 forks source link

Compiling for arm64-v8a #21

Closed xav12358 closed 6 years ago

xav12358 commented 6 years ago

Hello,

I try to use the compile_android.sh file to be able to compile for arm64-v8a in cpp.

I modify the compile_android.sh file like this:

# Add a new tensorflow target bundling the C API over the Android specific TF core lib
cat << EOF >> tensorflow/contrib/android/BUILD
cc_binary(

    name = "libtensorflow_all.so",
    srcs = [],
    copts = tf_copts() + [
        "-ffunction-sections",
        "-fdata-sections",
    ],
    linkopts = if_android([
        "-landroid",
        "-llog",
        "-lm",
        "-z defs",
        "-s",
    "--std=c++11",
    "-lpthread",
    "--config=monolithic",
        "-Wl,--gc-sections",
    # soname is required for the so to load on api > 22
        "-Wl,-soname=libtensorflow_all.so",
        "-Wl,--version-script",
        "--version-script=tensorflow/tf_version_script.lds",
    ]),
    linkshared = 1,
    linkstatic = 1,
    tags = [
        "manual",
        "notap",
    ],
    deps = [
        "//tensorflow/core:framework_internal",
        "//tensorflow/core:tensorflow",
        "//tensorflow/cc:cc_ops",
        "//tensorflow/cc:client_session",
        "//tensorflow/cc:scope",
        "//tensorflow/c:c_api",
    ],

)
EOF

When I compile it I get that error:

...................
WARNING: /home/xavier/.cache/bazel/_bazel_xavier/b4a3d41cf6e18601b16eb0b2e023194f/external/protobuf_archive/WORKSPACE:1: Workspace name in /home/xavier/.cache/bazel/_bazel_xavier/b4a3d41cf6e18601b16eb0b2e023194f/external/protobuf_archive/WORKSPACE (@com_google_protobuf) does not match the name given in the repository's definition (@protobuf_archive); this will cause a build error in future versions
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:avgpooling_op.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:batch_util.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:bounds_check.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops_common.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:cwise_ops_gradients.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_activations.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_attention.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_backward_cuboid_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_backward_spatial_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_cuboid_convolution.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_pooling.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_softmax.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_spatial_convolutions.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:eigen_volume_patch.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:fifo_queue.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:maxpooling_op.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:ops_util.cc' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:ops_util.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:padding_fifo_queue.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:pooling_ops_common.cc' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:pooling_ops_common.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:queue_base.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:queue_op.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/kernels:typed_queue.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_entry.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_scorer.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_beam_search.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_decoder.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/ctc:ctc_loss_util.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:naming.cc' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:naming.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:tensor_bundle.cc' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1045:12: in srcs attribute of cc_library rule //tensorflow/core:android_tensorflow_lib_lite: please do not import '//tensorflow/core/util/tensor_bundle:tensor_bundle.h' directly. You should either move the file to this package or depend on an appropriate rule there
WARNING: /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/core/BUILD:1866:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/nsync/public' resolves to 'external/nsync/public' not below the relative path of its package 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error might have been caused by the macro implementation in /home/xavier/Bureau/developpement/NeuralNetwork/tensorflow-build_gcc/target/tensorflow/tensorflow/tensorflow.bzl:1163:30
INFO: Analysed target //tensorflow/contrib/android:libtensorflow_all.so (59 packages loaded).
INFO: Found 1 target...
INFO: From Compiling external/com_googlesource_code_re2/re2/simplify.cc:
In file included from external/com_googlesource_code_re2/re2/simplify.cc:12:
external/com_googlesource_code_re2/util/logging.h:81:35: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  LogMessage(const LogMessage&) = delete;
                                  ^
external/com_googlesource_code_re2/util/logging.h:82:46: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  LogMessage& operator=(const LogMessage&) = delete;
                                             ^
external/com_googlesource_code_re2/util/logging.h:101:45: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  LogMessageFatal(const LogMessageFatal&) = delete;
                                            ^
external/com_googlesource_code_re2/util/logging.h:102:56: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  LogMessageFatal& operator=(const LogMessageFatal&) = delete;
                                                       ^
In file included from external/com_googlesource_code_re2/re2/simplify.cc:14:
external/com_googlesource_code_re2/re2/regexp.h:218:39: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  RegexpStatus(const RegexpStatus&) = delete;
                                      ^
external/com_googlesource_code_re2/re2/regexp.h:219:50: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  RegexpStatus& operator=(const RegexpStatus&) = delete;
                                                 ^
external/com_googlesource_code_re2/re2/regexp.h:270:33: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  CharClass(const CharClass&) = delete;
                                ^
external/com_googlesource_code_re2/re2/regexp.h:271:44: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  CharClass& operator=(const CharClass&) = delete;
                                           ^
external/com_googlesource_code_re2/re2/regexp.h:586:27: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  Regexp(const Regexp&) = delete;
                          ^
external/com_googlesource_code_re2/re2/regexp.h:587:38: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  Regexp& operator=(const Regexp&) = delete;
                                     ^
external/com_googlesource_code_re2/re2/regexp.h:622:47: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  CharClassBuilder(const CharClassBuilder&) = delete;
                                              ^
external/com_googlesource_code_re2/re2/regexp.h:623:58: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  CharClassBuilder& operator=(const CharClassBuilder&) = delete;
                                                         ^
In file included from external/com_googlesource_code_re2/re2/simplify.cc:15:
external/com_googlesource_code_re2/re2/walker-inl.h:98:27: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  Walker(const Walker&) = delete;
                          ^
external/com_googlesource_code_re2/re2/walker-inl.h:99:38: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  Walker& operator=(const Walker&) = delete;
                                     ^
external/com_googlesource_code_re2/re2/simplify.cc:130:43: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  CoalesceWalker(const CoalesceWalker&) = delete;
                                          ^
external/com_googlesource_code_re2/re2/simplify.cc:131:54: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  CoalesceWalker& operator=(const CoalesceWalker&) = delete;
                                                     ^
external/com_googlesource_code_re2/re2/simplify.cc:166:43: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  SimplifyWalker(const SimplifyWalker&) = delete;
                                          ^
external/com_googlesource_code_re2/re2/simplify.cc:167:54: warning: deleted function definitions are a C++11 extension [-Wc++11-extensions]
  SimplifyWalker& operator=(const SimplifyWalker&) = delete;
                                                     ^
18 warnings generated.
ERROR: /home/xavier/.cache/bazel/_bazel_xavier/b4a3d41cf6e18601b16eb0b2e023194f/external/com_googlesource_code_re2/BUILD:11:1: C++ compilation of rule '@com_googlesource_code_re2//:re2' failed (Exit 1): clang failed: error executing command 
  (cd /home/xavier/.cache/bazel/_bazel_xavier/b4a3d41cf6e18601b16eb0b2e023194f/execroot/org_tensorflow && \
  exec env - \
    LD_LIBRARY_PATH=/opt/ros/kinetic/lib:/usr/local/lib: \
    PATH=/opt/ros/kinetic/bin:/home/xavier/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld:/home/xavier/bin:/home/xavier/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/xavier/Android/Sdk/platform-tools:/home/xavier/android-ndk-r14b:/home/xavier/Bureau/developpement/androidscreencast/bin:/home/xavier/Bureau/developpement/androidscreencast:/home/xavier/Bureau/developpement/gerrit_tools:/home/xavier/android-studio/bin:/home/xavier/Bureau/developpement:/home/xavier/dev/common.tools/bin:/home/xavier/dev/gcc-arm-none-eabi-6-2017-q2-update/bin:/home/xavier/dev/dump_Cyril:/home/xavier/opt/gnu-mcu-eclipse/openocd/0.10.0-3-20170826-1813-dev/bin \
    PWD=/proc/self/cwd \
  external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -gcc-toolchain external/androidndk/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 -target aarch64-none-linux-android -ffunction-sections -funwind-tables -fstack-protector-strong -fpic -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -O2 -g -DNDEBUG -MD -MF bazel-out/arm64-v8a-opt/bin/external/com_googlesource_code_re2/_objs/re2/external/com_googlesource_code_re2/re2/prefilter_tree.d '-frandom-seed=bazel-out/arm64-v8a-opt/bin/external/com_googlesource_code_re2/_objs/re2/external/com_googlesource_code_re2/re2/prefilter_tree.o' -iquote external/com_googlesource_code_re2 -iquote bazel-out/arm64-v8a-opt/genfiles/external/com_googlesource_code_re2 -iquote external/bazel_tools -iquote bazel-out/arm64-v8a-opt/genfiles/external/bazel_tools -isystem external/bazel_tools/tools/cpp/gcc3 -pthread '--sysroot=external/androidndk/ndk/platforms/android-24/arch-arm64' -isystem external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include -isystem external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -c external/com_googlesource_code_re2/re2/prefilter_tree.cc -o bazel-out/arm64-v8a-opt/bin/external/com_googlesource_code_re2/_objs/re2/external/com_googlesource_code_re2/re2/prefilter_tree.o)
In file included from external/com_googlesource_code_re2/re2/prefilter_tree.cc:5:
In file included from external/com_googlesource_code_re2/re2/prefilter_tree.h:24:
In file included from external/com_googlesource_code_re2/util/sparse_array.h:102:
In file included from external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/type_traits: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 external/com_googlesource_code_re2/re2/prefilter_tree.cc:5:
In file included from external/com_googlesource_code_re2/re2/prefilter_tree.h:24:
external/com_googlesource_code_re2/util/sparse_array.h:116:22: error: no type named 'is_trivially_destructible' in namespace 'std'
  static_assert(std::is_trivially_destructible<IndexValue>::value,
                ~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:116:47: error: expected ')'
  static_assert(std::is_trivially_destructible<IndexValue>::value,
                                              ^
external/com_googlesource_code_re2/util/sparse_array.h:116:16: note: to match this '('
  static_assert(std::is_trivially_destructible<IndexValue>::value,
               ^
external/com_googlesource_code_re2/util/sparse_array.h:116:3: error: C++ requires a type specifier for all declarations
  static_assert(std::is_trivially_destructible<IndexValue>::value,
  ^
external/com_googlesource_code_re2/util/sparse_array.h:124:26: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  SparseArray(SparseArray&& src) /*noexcept*/;
                         ^
external/com_googlesource_code_re2/util/sparse_array.h:127:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  SparseArray& operator=(SparseArray&& src) /*noexcept*/;
                                    ^
external/com_googlesource_code_re2/util/sparse_array.h:185:28: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  iterator set(int i, Value&& v) {  // NOLINT
                           ^
external/com_googlesource_code_re2/util/sparse_array.h:192:46: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  std::pair<iterator, bool> insert(value_type&& v) {  // NOLINT
                                             ^
external/com_googlesource_code_re2/util/sparse_array.h:196:21: warning: variadic templates are a C++11 extension [-Wc++11-extensions]
  template <typename... Args>
                    ^
external/com_googlesource_code_re2/util/sparse_array.h:197:41: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  std::pair<iterator, bool> emplace(Args&&... args) {  // NOLINT
                                        ^
external/com_googlesource_code_re2/util/sparse_array.h:218:37: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  iterator set_existing(int i, Value&& v) {  // NOLINT
                                    ^
external/com_googlesource_code_re2/util/sparse_array.h:227:32: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  iterator set_new(int i, Value&& v) {  // NOLINT
                               ^
external/com_googlesource_code_re2/util/sparse_array.h:262:45: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  std::pair<iterator, bool> InsertInternal(U&& v) {
                                            ^
external/com_googlesource_code_re2/util/sparse_array.h:275:54: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  iterator SetInternal(bool allow_overwrite, int i, U&& v) {  // NOLINT
                                                     ^
external/com_googlesource_code_re2/util/sparse_array.h:295:40: warning: rvalue references are a C++11 extension [-Wc++11-extensions]
  iterator SetExistingInternal(int i, U&& v) {  // NOLINT
                                       ^
external/com_googlesource_code_re2/util/sparse_array.h:329:13: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
  int size_ = 0;
            ^
external/com_googlesource_code_re2/util/sparse_array.h:330:17: warning: in-class initialization of non-static data member is a C++11 extension [-Wc++11-extensions]
  int max_size_ = 0;
                ^
external/com_googlesource_code_re2/util/sparse_array.h:331:8: error: no type named 'unique_ptr' in namespace 'std'
  std::unique_ptr<int[]> sparse_to_dense_;
  ~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:331:18: error: expected member name or ';' after declaration specifiers
  std::unique_ptr<int[]> sparse_to_dense_;
  ~~~~~~~~~~~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:332:8: error: no type named 'unique_ptr' in namespace 'std'
  std::unique_ptr<IndexValue[]> dense_;
  ~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:332:18: error: expected member name or ';' after declaration specifiers
  std::unique_ptr<IndexValue[]> dense_;
  ~~~~~~~~~~~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:143:12: error: use of undeclared identifier 'dense_'
    return dense_.get();
           ^
external/com_googlesource_code_re2/util/sparse_array.h:146:12: error: use of undeclared identifier 'dense_'
    return dense_.get() + size_;
           ^
external/com_googlesource_code_re2/util/sparse_array.h:150:12: error: use of undeclared identifier 'dense_'
    return dense_.get();
           ^
external/com_googlesource_code_re2/util/sparse_array.h:153:12: error: use of undeclared identifier 'dense_'
    return dense_.get() + size_;
           ^
external/com_googlesource_code_re2/util/sparse_array.h:186:38: error: no member named 'move' in namespace 'std'
    return SetInternal(true, i, std::move(v));
                                ~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:193:32: error: no member named 'move' in namespace 'std'
    return InsertInternal(std::move(v));
                          ~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:198:43: error: no member named 'forward' in namespace 'std'
    return InsertInternal(value_type(std::forward<Args>(args)...));
                                     ~~~~~^
external/com_googlesource_code_re2/util/sparse_array.h:198:51: error: 'Args' does not refer to a value
    return InsertInternal(value_type(std::forward<Args>(args)...));
                                                  ^
external/com_googlesource_code_re2/util/sparse_array.h:196:25: note: declared here
  template <typename... Args>
                        ^
external/com_googlesource_code_re2/util/sparse_array.h:203:14: error: use of undeclared identifier 'dense_'
      return dense_.get() + sparse_to_dense_[i];
             ^
external/com_googlesource_code_re2/util/sparse_array.h:203:29: error: use of undeclared identifier 'sparse_to_dense_'
      return dense_.get() + sparse_to_dense_[i];
                            ^
external/com_googlesource_code_re2/util/sparse_array.h:209:14: error: use of undeclared identifier 'dense_'
      return dense_.get() + sparse_to_dense_[i];
             ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
13 warnings and 20 errors generated.
Target //tensorflow/contrib/android:libtensorflow_all.so failed to build
INFO: Elapsed time: 27.624s, Critical Path: 0.89s
FAILED: Build did NOT complete successfully

How can I compile it for arm64-v8a in cpp?

fredszaq commented 6 years ago

Hi ! which version of tensorflow are you compiling ?

xav12358 commented 6 years ago

Here are more information about my computer: OS Platform and Distribution : Ubuntu 16.04 TensorFlow installed from source TensorFlow version 1.4.0 Bazel version 0.9

I also try to compile libtensorflow_cc.so (which seems to be the cpp compiled version of tensorflow) but I also get errors:

bazel build --config=android_arm64 -c opt //tensorflow:libtensorflow_cc.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain WARNING: /home/xavier/.cache/bazel/_bazel_xavier/ef54af8645dec4f38c438d8e1c779747/external/protobuf_archive/WORKSPACE:1: Workspace name in /home/xavier/.cache/bazel/_bazel_xavier/ef54af8645dec4f38c438d8e1c779747/external/protobuf_archive/WORKSPACE (@com_google_protobuf) does not match the name given in the repository's definition (@protobuf_archive); this will cause a build error in future versions ERROR: No default_toolchain found for cpu 'arm64-v8a'. Valid cpus are: [ k8, armeabi-v7a, x64_windows, x64_windows_msvc, x64_windows_msys, s390x, ios_x86_64, ] INFO: Elapsed time: 1.217s FAILED: Build did NOT complete successfully (4 packages loaded)

fredszaq commented 6 years ago

hum, I think you're trying to build a few things that are not "android ready" . In you deps array

deps = [
        "//tensorflow/core:framework_internal",
        "//tensorflow/core:tensorflow",
        "//tensorflow/cc:cc_ops",
        "//tensorflow/cc:client_session",
        "//tensorflow/cc:scope",
        "//tensorflow/c:c_api",
    ],

you don't depend on //tensorflow/core:android_tensorflow_lib but //tensorflow/core:tensorflow which if I remember well has some non android compatible deps...

xav12358 commented 6 years ago

So the solution is to modify "//tensorflow/core:tensorflow" to "//tensorflow/core:tensorflow_lib" ?

fredszaq commented 6 years ago

more probably //tensorflow/core:android_tensorflow_lib but you'll need to figure out if there is all that's needed in here to make the CPP api work in here... there are quite a few parts of the implementation that are swapped out when building for android, you'll need to explore the bazel BUILD files to see what's happening

xav12358 commented 6 years ago

I don't think this is enough:

`INFO: From Compiling external/protobuf_archive/src/google/protobuf/struct.pb.cc: external/protobuf_archive/src/google/protobuf/struct.pb.cc:115:3: warning: offset of on non-POD type '::google::protobuf::ValueDefaultTypeInternal' [-Winvalid-offsetof] offsetof(::google::protobuf::ValueDefaultTypeInternal, nullvalue), ^ ~~~ external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/stddef.h:120:24: note: expanded from macro 'offsetof'

define offsetof(t, d) __builtin_offsetof(t, d)

                   ^                     ~

external/protobuf_archive/src/google/protobuf/struct.pb.cc:116:3: warning: offset of on non-POD type '::google::protobuf::ValueDefaultTypeInternal' [-Winvalid-offsetof] offsetof(::google::protobuf::ValueDefaultTypeInternal, numbervalue), ^ ~~~~~ external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/stddef.h:120:24: note: expanded from macro 'offsetof'

define offsetof(t, d) __builtin_offsetof(t, d)

                   ^                     ~

external/protobuf_archive/src/google/protobuf/struct.pb.cc:117:3: warning: offset of on non-POD type '::google::protobuf::ValueDefaultTypeInternal' [-Winvalid-offsetof] offsetof(::google::protobuf::ValueDefaultTypeInternal, stringvalue), ^ ~~~~~ external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/stddef.h:120:24: note: expanded from macro 'offsetof'

define offsetof(t, d) __builtin_offsetof(t, d)

                   ^                     ~

external/protobuf_archive/src/google/protobuf/struct.pb.cc:118:3: warning: offset of on non-POD type '::google::protobuf::ValueDefaultTypeInternal' [-Winvalid-offsetof] offsetof(::google::protobuf::ValueDefaultTypeInternal, boolvalue), ^ ~~~ external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/stddef.h:120:24: note: expanded from macro 'offsetof'

define offsetof(t, d) __builtin_offsetof(t, d)

                   ^                     ~

external/protobuf_archive/src/google/protobuf/struct.pb.cc:119:3: warning: offset of on non-POD type '::google::protobuf::ValueDefaultTypeInternal' [-Winvalid-offsetof] offsetof(::google::protobuf::ValueDefaultTypeInternal, structvalue), ^ ~~~~~ external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/stddef.h:120:24: note: expanded from macro 'offsetof'

define offsetof(t, d) __builtin_offsetof(t, d)

                   ^                     ~

external/protobuf_archive/src/google/protobuf/struct.pb.cc:120:3: warning: offset of on non-POD type '::google::protobuf::ValueDefaultTypeInternal' [-Winvalid-offsetof] offsetof(::google::protobuf::ValueDefaultTypeInternal, listvalue), ^ ~~~ external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/../lib64/clang/3.8.275480/include/stddef.h:120:24: note: expanded from macro 'offsetof'

define offsetof(t, d) __builtin_offsetof(t, d)

                   ^                     ~

6 warnings generated. ERROR: /home/xavier/.cache/bazel/_bazel_xavier/b4a3d41cf6e18601b16eb0b2e023194f/external/lmdb/BUILD:8:1: C++ compilation of rule '@lmdb//:lmdb' failed (Exit 1): clang failed: error executing command (cd /home/xavier/.cache/bazel/_bazel_xavier/b4a3d41cf6e18601b16eb0b2e023194f/execroot/org_tensorflow && \ exec env - \ LD_LIBRARY_PATH=/opt/ros/kinetic/lib:/usr/local/lib: \ PATH=/opt/ros/kinetic/bin:/home/xavier/Android/Sdk/ndk-bundle/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/ld:/home/xavier/bin:/home/xavier/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/home/xavier/Android/Sdk/platform-tools:/home/xavier/android-ndk-r14b:/home/xavier/Bureau/developpement/androidscreencast/bin:/home/xavier/Bureau/developpement/androidscreencast:/home/xavier/Bureau/developpement/gerrit_tools:/home/xavier/android-studio/bin:/home/xavier/Bureau/developpement:/home/xavier/dev/common.tools/bin:/home/xavier/dev/gcc-arm-none-eabi-6-2017-q2-update/bin:/home/xavier/dev/dump_Cyril:/home/xavier/opt/gnu-mcu-eclipse/openocd/0.10.0-3-20170826-1813-dev/bin \ PWD=/proc/self/cwd \ external/androidndk/ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -gcc-toolchain external/androidndk/ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64 -target aarch64-none-linux-android -ffunction-sections -funwind-tables -fstack-protector-strong -fpic -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes -O2 -g -DNDEBUG -MD -MF bazel-out/arm64-v8a-opt/bin/external/lmdb/_objs/lmdb/external/lmdb/mdb.d -iquote external/lmdb -iquote bazel-out/arm64-v8a-opt/genfiles/external/lmdb -iquote external/bazel_tools -iquote bazel-out/arm64-v8a-opt/genfiles/external/bazel_tools -isystem external/bazel_tools/tools/cpp/gcc3 -w '--sysroot=external/androidndk/ndk/platforms/android-24/arch-arm64' -isystem external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include -isystem external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a/include -isystem external/androidndk/ndk/sources/cxx-stl/gnu-libstdc++/4.9/include/backward -c external/lmdb/mdb.c -o bazel-out/arm64-v8a-opt/bin/external/lmdb/_objs/lmdb/external/lmdb/mdb.o) external/lmdb/mdb.c:4853:53: error: use of undeclared identifier 'PTHREAD_MUTEX_ROBUST' if (!rc) rc = pthread_mutexattr_setrobust(&mattr, PTHREAD_MUTEX_ROBUST); ^ 1 error generated. Target //tensorflow/contrib/android:libtensorflow_all.so failed to build INFO: Elapsed time: 205.387s, Critical Path: 14.32s FAILED: Build did NOT complete successfully ` It is strange not to find examples of compiled c++ API project on arm64 on internet. Does everybody use C API to use tensorflow on Android?

fredszaq commented 6 years ago

AFAIK most people use the java api provided by google, at snips we use the C api because we use rust

xav12358 commented 6 years ago

Are there examples of project who use and load in JNI the graph for image classification?

fredszaq commented 6 years ago

https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/lite/java/demo

as per the readme here, there is a C++ api bundled in the official tflite package, so you don't need to compile it yourself

xav12358 commented 6 years ago

Ok thank you I will try it. In the project there is no JNI file?

yonderblue commented 6 years ago

Anyone ever figure out what to do about PTHREAD_MUTEX_ROBUST on arm64?

bharathsekar commented 5 years ago

PTHREAD_MUTEX_ROBUST issue is from the lmdb module. As per the thread https://www.openldap.org/lists/openldap-devel/201511/msg00010.html, android lacks the robust mutex support. Hence, this can be turned of with -DMDB_USE_ROBUST=0 option.

A defines option can be added under third_party/lmdb.BUILD file to define MDB_USE_ROBUST to 0 in case of android builds through bazel

Somthing like

cc_library( ..., ..., defines = select({ ":android": [ "MDB_USE_ROBUST=0", ], "//conditions:default": [], }), ) Hope this helps

Edit: I also see that android BUILD is not configured for lmdb, so add the following in the file

config_setting( name = "android", values = {"crosstool_top": "//external:android/crosstool"}, )