Skip to content

cross compile tensorflow c++ library for android #1

@lingbao00

Description

@lingbao00

i am doing cross compile tensorflow c++ library for android,and i had get the c library for android using ndk ,add like this:
cc_binary(
name = "libtensorflow.so",
srcs = [],
copts = tf_copts() + [
"-ffunction-sections",
"-fdata-sections",
],
linkopts = if_android([
"-landroid",
"-llog",
"-lm",
"-z defs",
"-s",
"-Wl,--gc-sections",
# soname is required for the so to load on api > 22
"-Wl,-soname=libtensorflow.so",
"-Wl,--version-script",
"//tensorflow/c:version_script.lds",
]),
linkshared = 1,
linkstatic = 1,
tags = [
"manual",
"notap",
],
deps = [
"//tensorflow/c:c_api",
"//tensorflow/c:version_script.lds",
"//tensorflow/core:android_tensorflow_lib",
],
)
it success.but i try c++ ,failed,and i add like this:
cc_binary(
name = "libtensorflow_cc.so",
srcs = [],
copts = tf_copts() + [
"-ffunction-sections",
"-fdata-sections",
],
linkopts = if_android([
"-landroid",
"-llog",
"-lm",
"-z defs",
"-s",
"-Wl,--gc-sections",
# soname is required for the so to load on api > 22
"-Wl,-soname=libtensorflow_cc.so",
]),
linkshared = 1,
linkstatic = 1,
tags = [
"manual",
"notap",
],
deps = [
"//tensorflow/c:c_api",
"//tensorflow/cc:cc_ops",
"//tensorflow/cc:client_session",
"//tensorflow/cc:scope",
"//tensorflow/core:android_tensorflow_lib",
],
)
it got the error:
ERROR: /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/core/BUILD:1395:1: no such target '//tensorflow/tools/git:gen/spec.json': target 'gen/spec.json' not declared in package 'tensorflow/tools/git' defined by /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'
ERROR: /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/core/BUILD:1395:1: no such target '//tensorflow/tools/git:gen/head': target 'gen/head' not declared in package 'tensorflow/tools/git' defined by /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'
ERROR: /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/core/BUILD:1395:1: no such target '//tensorflow/tools/git:gen/branch_ref': target 'gen/branch_ref' not declared in package 'tensorflow/tools/git' defined by /home/z/e0028/workspace/tensorflow-build/target/tensorflow/tensorflow/tools/git/BUILD and referenced by '//tensorflow/core:version_info_gen'
ERROR: Analysis of target '//tensorflow/contrib/android:libtensorflow_cc.so' failed; build aborted.

can you help me to fix it,thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions