I'm currently trying to compile the target //tensorflow:libtensorflow_cc.so of TensorFlow with bazel for Android. I need this library in order to get the javacpp-presets for TensorFlow working with Android.
I tried the following statement:
bazel build -c opt //tensorflow:libtensorflow_cc.so --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --verbose_failures
Which however results in the error that S_IREAD, S_IWRITE cannot be found:
external/gif_archive/giflib-5.1.4/lib/egif_lib.c:62:6: error: 'S_IREAD' undeclared (first use in this function)
S_IREAD | S_IWRITE);
^
external/gif_archive/giflib-5.1.4/lib/egif_lib.c:62:6: note: each undeclared identifier is reported only once for each function it appears in
external/gif_archive/giflib-5.1.4/lib/egif_lib.c:62:16: error: 'S_IWRITE' undeclared (first use in this function)
S_IREAD | S_IWRITE);
^
Target //tensorflow:libtensorflow_cc.so failed to build
Inspired by the Android build in the Android Demo build, I also tried to change the cc_binary definition to the following code, but still got the same error.
cc_binary(
name = "libtensorflow_cc.so",
copts = tf_copts(),
linkopts = [
"-landroid",
"-ljnigraphics",
"-llog",
"-lm",
"-z defs",
"-s",
"-Wl,--icf=all", # Identical Code Folding
],
linkshared = 1,
linkstatic = 1,
deps = [
"//tensorflow/c:c_api",
"//tensorflow/cc:cc_ops",
"//tensorflow/core:tensorflow",
],
)
From googling, I found out that the S_IWRITE flags are deprecated and therefore have never been implemented in Android. However, I have no idea how to get around this problem.
To sum it up: Do you know how I can build the libtensorflow_cc.so target for Android? The library build in the Android example is not enough for me because I also need the cc_ops included.