tensorflow: bazel error: name 'http_archive' is not defined
I want to build libtensorflowLite.so for Android
git clone --recurse-submodules https://github.com/tensorflow/tensorflow.git -b r1.12
cd tensorflow
vim WORKSPACE
1. modify WORKSPACE:
android_sdk_repository(
name = "androidsdk",
api_level = 29,
build_tools_version = "29.0.0",
path = "/Users/gongjia/Library/Android/sdk",
)
# Android NDK r12b is recommended (higher may cause issues with Bazel)
android_ndk_repository(
name="androidndk",
# path="/Users/gongjia/Library/Android/sdk/ndk-bundle",
path="/Users/gongjia/Library/Android/sdk/android-ndk-r14b",
api_level=21
)
2. add in tensorflow/contrib/lite/BUILD
cc_binary(
name = "libtensorflowLite.so",
linkopts = ["-shared", "-Wl,-soname=libtensorflowLite.so"],
visibility = ["//visibility:public"],
linkshared = 1,
copts = tflite_copts(),
deps = [
":framework",
"//tensorflow/contrib/lite/kernels:builtin_ops",
],
)
3. exec:
bazel build -c opt //tensorflow/contrib/lite:libtensorflowLite.so --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cxxopt="-std=c++11" --verbose_failures
4. result:
ERROR: /Users/gongjia/Documents/github/tensorflow/WORKSPACE:3:1: name 'http_archive' is not defined
ERROR: Error evaluating WORKSPACE file
ERROR: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//closure': error loading package 'external': Could not load //external package
ERROR: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//closure': error loading package 'external': Could not load //external package
INFO: Elapsed time: 0.082s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
5. Info:
tensorflow: r1.12 configure: default macOS Mojave 10.14.3 python:2.7 bazel: 0.24.0
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (2 by maintainers)
@307509256 Please check the tested build config here. For TF1.12, you need to downgrade Bazel to 0.15.0. For TF1.13.1, you need to use Bazel 0.19.2. Thanks!
The problem is solved, thank you! another question , I build success, the size of file “bazel-bin/tensorflow/contrib/lite/libtensorflowLite.so” is 49M, but I download from maven is 2.3M url: http://jcenter.bintray.com/org/tensorflow/tensorflow-lite/1.12.0/