为Android构建tensorflowlite.so失败,如何修复错误“未定义名称'closure_proto_library'”

时间:2019-01-29 09:02:56

标签: android tensorflow android-ndk bazel tensorflow-lite

tensorflow版本r1.9
bazel 0.11.1
ndk r14
api级23

命令:

bazel build //tensorflow/contrib/lite:libtensorflowLite.so --crosstool_top=//external:android/crosstool --cpu=arm64-v8a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cxxopt="-std=c++11"

错误:

ERROR: /home/user/mypro/tensorflow/tensorflow/core/BUILD:148:1: file '@io_bazel_rules_closure//closure:defs.bzl' does not contain symbol 'closure_proto_library' (did you mean 'closure_js_proto_library'?)
ERROR: /home/user/mypro/tensorflow/tensorflow/core/BUILD:153:1: file '@io_bazel_rules_closure//closure:defs.bzl' does not contain symbol 'closure_proto_library' (did you mean 'closure_js_proto_library'?)
ERROR: /home/user/mypro/tensorflow/tensorflow/core/BUILD:271:1: name 'closure_proto_library' is not defined
ERROR: /home/user/mypro/tensorflow/tensorflow/core/BUILD:290:1: Target '//tensorflow/core:platform/platform.h' contains an error and its package is in error and referenced by '//tensorflow/core:lib_platform'
ERROR: /home/user/mypro/tensorflow/tensorflow/contrib/lite/BUILD:95:1: Target '//tensorflow/core:lib_platform' contains an error and its package is in error and referenced by '//tensorflow/contrib/lite:string'
ERROR: Analysis of target '//tensorflow/contrib/lite:libtensorflowLite.so' failed; build aborted: Loading failed
INFO: Elapsed time: 12.701s
FAILED: Build did NOT complete successfully (24 packages loaded)```

1 个答案:

答案 0 :(得分:1)

很可能bazel工具和tensorflow的版本之间存在版本不匹配的情况。您可以在这里使用应使用的tensorflow版本中推荐的bazel工具:https://www.tensorflow.org/install/source

在您的情况下,推荐的构建工具是Bazel 0.11.0,并且使用Bazel 0.11.1版本(尽管这是次要的版本)。