By Nimitz14


2018-11-08 19:00:45 8 Comments

I'm trying to use tensorflow lite on android. I'm getting an error during compilation with android studio:

undefined reference to 'tflite::InterpreterBuilder::operator()(std::__ndk1::unique_ptr<tflite::Interpreter, std::__ndk1::default_delete<tflite::Interpreter> >*)'

I've managed to get a reproducible example while trying to compile this minimal example from the tf repo.

Steps to get the error

  1. Download the android ndk (I've tried both 15c and 16b and they both failed) . Call build/tools/make_standalone_toolchain.py --arch arm --api 21 --stl=libc++ --install-dir android-toolchain

  2. Build libtensorflow, this is in my build file.

tensorflow/lite/BUILD

cc_binary(
    name = "libtensorflowlite.so",
    linkopts=[
        "-shared",
        "-Wl,-soname=libtensorflowlite.so",
    ],  
    linkshared = 1,
    copts = tflite_copts(),
    deps = [ 
        ":framework",
        "//tensorflow/lite/kernels:builtin_ops",
    ],  
)

I call it like:

bazel build //tensorflow/lite:libtensorflowlite.so --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a [email protected]_tools//tools/cpp:toolchain --cxxopt="-std=c++11"
  1. I clone the flatbuffer repo (a dependency) and compile it.

  2. Then I try and compile minimal.cc.

I call it like:

android-toolchain/bin/clang++  -std=c++11 -Igit/tensorflow-android -Igit/flatbuffers/include -Lgit/tensorflow-android -Lgit/flatbuffers/build minimal.cc -ltensorflowlite -lflatbuffers

(libtensorflow.so is in git/tensorflow-android, libflatbuffers.a in git/flatbuffers/build)

What's going on? I have no idea why this method is being called, I'm not calling the object with two arguments.

0 comments

Related Questions

Sponsored Content

0 Answered Questions

2 Answered Questions

[SOLVED] Running a Tensorflow model on Android

2 Answered Questions

[SOLVED] Compiling Tensorflow with a custom Clang + Libc++ (instead of stdlibc++)

0 Answered Questions

-O3 optimization for tensorflow

0 Answered Questions

how to use bazel compile tensorflow demo with custom toolchain in Ubuntu

0 Answered Questions

bazel cross compile tensorflow with opencl support

1 Answered Questions

[SOLVED] when i use bazel to bulid libtensorflow_inference.so

2 Answered Questions

[SOLVED] Build error with TensorFlow Android demo

  • 2017-01-05 14:04:20
  • Noam Segev
  • 456 View
  • 1 Score
  • 2 Answer
  • Tags:   android tensorflow

1 Answered Questions

[SOLVED] Benchmarking Quantization on Android

Sponsored Content