skip to Main Content

My tflite directory is as follows:

/home/me/tensorflow_src/tensorflow/lite/

However, I fail to import it in my C++ project:

#include "tensorflow/lite/interpreter.h" // getting a not found error

How can I add resolve this error? My assumption is that I’d need to add the tflite to my bash to make it available for all of my projects. How can I add tflite to the bash file?

This is my CMAKE file:

cmake_minimum_required(VERSION 3.22)
project(mediafile_device_crossverification)

set(CMAKE_CXX_STANDARD 17)

set(OpenCV FOUND 1)
find_package(OpenCV REQUIRED)
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable(mediafile_device_crossverification main.cpp src/VideoProcessing.cpp src/VideoProcessing.h)

2

Answers


  1. There are various options:

    First option: Install/copy the tensorflow header files to e.g. /urs/local/include that folder is usually in the system include path by default.

    Second option: GCC has some environment variables that can be used to modify the system include path. C_INCLUDE_PATH and CPLUS_INCLUDE_PATH, your can add them to .bashrc to set them when you login. See: https://gcc.gnu.org/onlinedocs/cpp/Environment-Variables.html

    Third option is to add /home/me/tensorflow_src to the include path in the CMakefile.

    When searching the include path #include <tensorflow/lite/interpreter.h> should be used.

    Login or Signup to reply.
  2. You can’t really make it available for the entire system with the way TFLite’s CMake is currently configured.

    There’s a section in TFLite’s documentation which shows you how to build a project depending on it.

    A bit further up there’s also a note why the library cannot be built stand-alone for time time being:

    Note: This generates a static library libtensorflow-lite.a in the current directory but the library isn’t self-contained since all the transitive dependencies are not included. To use the library properly, you need to create a CMake project. Please refer the "Create a CMake project which uses TensorFlow Lite" section.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search