Tensorflow c++ api 对`tflite::DefaultErrorReporter()'的未定义引用

阿什·马加尔

我使用静态构建在 Ubuntu 16.04 上成功构建了 tensorflow_cc。

我正在测试我从 tflite 指南中获取的一个小代码:

  $> cat test1.cpp

  #include <cstdio>
  #include "tensorflow/lite/interpreter.h"
  #include "tensorflow/lite/kernels/register.h"
  #include "tensorflow/lite/model.h"

  using namespace tflite;

  int main(int argc, char* argv[]) {
  if (argc != 2) {
  fprintf(stderr, "minimal \n");
  return 1;
  }
  const char* filename = argv[1];

  std::unique_ptrtflite::FlatBufferModel model =
  tflite::FlatBufferModel::BuildFromFile(filename);
  return 0;
  }

我收到此错误:

  [ 50%] Building CXX object CMakeFiles/example.dir/example.cpp.o
  [100%] Linking CXX executable example
  CMakeFiles/example.dir/example.cpp.o: In function main': example.cpp:(.text+0x57):                               
  undefined reference to tflite::DefaultErrorReporter()'
  example.cpp:(.text+0x6d): undefined reference to                               
  tflite::FlatBufferModel::BuildFromFile(char const*, tflite::ErrorReporter*)'             
  CMakeFiles/example.dir/example.cpp.o: In function 
  std::default_deletetflite::FlatBufferModel::operator()(tflite::FlatBufferModel*) const':
  example.cpp 
  (.text.ZNKSt14default_deleteIN6tflite15Flat 
  BufferModelEEclEPS1[ZNKSt14default_deleteIN6tflite15FlatBufferModelEEclEPS1]+0x1e): 
  undefined reference to `tflite::FlatBufferModel::~FlatBufferModel()'
  collect2: error: ld returned 1 exit status
  CMakeFiles/example.dir/build.make:85: recipe for target 'example' failed
  make[2]: *** [example] Error 1
  CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/example.dir/all' failed
  make[1]: *** [CMakeFiles/example.dir/all] Error 2
  Makefile:83: recipe for target 'all' failed
  make: *** [all] Error 2

有关如何进行的任何建议?

特里猪

它在https://github.com/tensorflow/tensorflow/issues/36661上得到了回答。出于某种奇怪的原因,您需要先向链接器提供目标文件,而不是 tflite 库。

仅供参考https://eli.thegreenplace.net/2013/07/09/library-order-in-static-linking

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章