Search code examples
androidtensorflowbazel

Bazel error "this rule is missing dependency declarations for the following files" when building tensorflow for android


I'm trying to build tensorflow for android. I'd like to use the DecodeJpeg op on android. Hence I've added the file, decode_image_op.cc, in which it is declared to build file.

This is the command I run to build tensorflow

bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so  --crosstool_top=//external:android/crosstool  --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=arm64-v8a

This throws the following error

ERROR: /tensorflow/core/kernels/BUILD:4950:1: undeclared inclusion(s) in rule '//tensorflow/core/kernels:android_tensorflow_kernels':
this rule is missing dependency declarations for the following files included by 'tensorflow/core/kernels/decode_image_op.cc':
  '/tensorflow/core/lib/jpeg/jpeg_mem.h'
  '/tensorflow/core/platform/jpeg.h'

Where should I add these header files to resolve this error?


Solution

  • It looks like you can add the cc_library target //tensorflow/core/kernels:android_tensorflow_image_op in the deps attribute of the cc_binary target //tensorflow/contrib/android:libtensorflow_inference.so.

    //tensorflow/core/kernels:android_tensorflow_image_op already defines decode_image_op.cc and its dependencies.