cmake_minimum_required(VERSION 3.30)
project(TFLiteCheck)
include has 2 subdirectories: tensorflow and flatbuffers
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/…/tflite-dist/include/)
lib has 3 file: tensorflowlite.dll.if.lib flatbuffers.lib tensorflowlite.dll
find_library(TFLITE tensorflowlite.dll.if.lib HINTS ${CMAKE_CURRENT_SOURCE_DIR}/…/tflite-dist/libs/windows_x64/)
find_library(FLATBUFFERS flatbuffers.lib HINTS ${CMAKE_CURRENT_SOURCE_DIR}/…/tflite-dist/libs/windows_x64/)
add_executable(TFLiteCheck main.cpp)
target_link_libraries(TFLiteCheck PRIVATE ${TFLITE} ${FLATBUFFERS})
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/…/tflite-dist/libs/windows_x64/tensorflowlite.dll ${CMAKE_BINARY_DIR}/Release/
)
For the above cmakelists
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x5d): undefined reference to tflite::DefaultErrorReporter()' CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x75): undefined reference to
tflite::FlatBufferModel::BuildFromFile(char const*, tflite::ErrorReporter*)’
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0xcd): undefined reference to tflite::ops::builtin::BuiltinOpResolver::BuiltinOpResolver()' CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0xf0): undefined reference to
tflite::InterpreterBuilder::InterpreterBuilder(tflite::FlatBufferModel const&, tflite::OpResolver const&)’
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x113): undefined reference to tflite::InterpreterBuilder::operator()(std::unique_ptr<tflite::Interpreter, std::default_delete<tflite::Interpreter> >*)' CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x17b): undefined reference to
tflite::Interpreter::AllocateTensors()’
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1d9): undefined reference to tflite::PrintInterpreterState(tflite::Interpreter*)' CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1ed): undefined reference to
tflite::Interpreter::Invoke()’
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x24b): undefined reference to tflite::PrintInterpreterState(tflite::Interpreter*)' CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x26a): undefined reference to
tflite::InterpreterBuilder::~InterpreterBuilder()’
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x29e): undefined reference to tflite::InterpreterBuilder::~InterpreterBuilder()' CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN6tflite17MutableOpResolverD2Ev[__ZN6tflite17MutableOpResolverD2Ev]+0xa): undefined reference to
vtable for tflite::MutableOpResolver’
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZN6tflite3ops7builtin17BuiltinOpResolverD1Ev[__ZN6tflite3ops7builtin17BuiltinOpResolverD1Ev]+0xa): undefined reference to vtable for tflite::ops::builtin::BuiltinOpResolver' CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text$_ZNKSt14default_deleteIN6tflite15FlatBufferModelEEclEPS1_[__ZNKSt14default_deleteIN6tflite15FlatBufferModelEEclEPS1_]+0x14): undefined reference to
tflite::FlatBufferModel::~FlatBufferModel()’
CMakeFiles\TFLiteCheck.dir/objects.a(main.cpp.obj):main.cpp:(.text$ZNKSt14default_deleteIN6tflite11InterpreterEEclEPS1[_ZNKSt14default_deleteIN6tflite11InterpreterEEclEPS1]+0x14): undefined reference to `tflite::Interpreter::~Interpreter()’
collect2.exe: error: ld returned 1 exit status
CMakeFiles\TFLiteCheck.dir\build.make:100: recipe for target ‘TFLiteCheck.exe’ failed
make[2]: *** [TFLiteCheck.exe] Error 1
CMakeFiles\Makefile2:81: recipe for target ‘CMakeFiles/TFLiteCheck.dir/all’ failed
make[1]: *** [CMakeFiles/TFLiteCheck.dir/all] Error 2
Makefile:89: recipe for target ‘all’ failed
make: *** [all] Error 2
Above error is being shown.