tensorflow: TensorFlow Lite: undefined reference to `flatbuffers::ClassicLocale::instance_'

Please make sure that this is a build/installation issue. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:build_template

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 18.04
  • TensorFlow installed from (source or binary): source
  • TensorFlow version: r1.13
  • Python version: 3.5
  • Installed using virtualenv? pip? conda?: virtualenv
  • Bazel version (if compiling from source): N/A
  • GCC/Compiler version (if compiling from source): 7.4.0
  • CUDA/cuDNN version: N/A
  • GPU model and memory: N/A

Describe the problem I was following the instructions to crosscompile TensorFlow Lite for my Raspberry Pi. I got the error messages showing the undefined reference to flatbuffers. I believe all the dependencies for Lite are downloaded by the download_dependencies.sh script, but I do not have Bazel installed. Is Bazel necessary for compiling TensorFlow Lite?

Any other info / logs

/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/lib/libtensorflow-lite.a(while.o): In function `tflite::ops::custom::while_kernel::Init(TfLiteContext*, char const*, unsigned int)':
while.cc:(.text+0x1648): undefined reference to `flatbuffers::ClassicLocale::instance_'
/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/lib/libtensorflow-lite.a(audio_spectrogram.o): In function `tflite::ops::custom::audio_spectrogram::Init(TfLiteContext*, char const*, unsigned int)':
audio_spectrogram.cc:(.text+0xe0c): undefined reference to `flatbuffers::ClassicLocale::instance_'
/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/lib/libtensorflow-lite.a(detection_postprocess.o): In function `tflite::ops::custom::detection_postprocess::Init(TfLiteContext*, char const*, unsigned int)':
detection_postprocess.cc:(.text+0x211c): undefined reference to `flatbuffers::ClassicLocale::instance_'
/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/lib/libtensorflow-lite.a(detection_postprocess.o): In function `flexbuffers::Reference::AsInt64() const':
detection_postprocess.cc:(.text._ZNK11flexbuffers9Reference7AsInt64Ev[_ZNK11flexbuffers9Reference7AsInt64Ev]+0x264): undefined reference to `flatbuffers::ClassicLocale::instance_'
/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/lib/libtensorflow-lite.a(if.o): In function `tflite::ops::custom::if_kernel::Init(TfLiteContext*, char const*, unsigned int)':
if.cc:(.text+0xf8c): undefined reference to `flatbuffers::ClassicLocale::instance_'
/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/lib/libtensorflow-lite.a(mfcc.o):mfcc.cc:(.text+0x118c): more undefined references to `flatbuffers::ClassicLocale::instance_' follow
collect2: error: ld returned 1 exit status
tensorflow/lite/tools/make/Makefile:267: recipe for target '/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/bin/minimal' failed
make: *** [/home/user/GitRepo/tensorflow/tensorflow/lite/tools/make/gen/rpi_armv7l/bin/minimal] Error 1
make: *** Waiting for unfinished jobs....

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 32 (3 by maintainers)

Most upvoted comments

can someone attach the makefile please? I’m having trouble implementing the changes and the link for the makefile that has been posted does not work for me

Ok, this one for you -https://mega.nz/#!eYVSzaII!cJbqTnJa2QYotKpJtnFnLl9gaIl4z9rnAizmOn_yQQ8 (but i don’t know the country Yandex is blocked, you are the first). I will not use google drive, dropbox or any other global-spy services.

I made a patch in Makefile for this -

  1. add $(wildcard tensorflow/lite/tools/make/downloads/flatbuffers/src/util.cpp) at ther end of CORE_CC_ALL_SRC
  2. change LIB_OBJS and BENCHMARK_OBJS to $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(TF_LITE_CC_SRCS))))) and $(patsubst %.cc,%.o,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(BENCHMARK_SRCS)))))
  3. add $(OBJDIR)%.o: %.cpp @mkdir -p $(dir $@) $(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@ near other OBJDIR declarations.

Now it builds and works.

Hi @T-Troll … Thanks for the update. I have added the workarounds mentioned in issue 26731 along with your changes to the Makefile.

Now I am successful in building the library for aarch64 architecture. Gist of the new Makefile for aarch64

@jvishnuvardhan this issue is still in the codebase. I’m not knowledgeable enough about the TF codebase to know whether this solution is a hacky workaround or a clean solution — but I don’t think the issue should be closed. Think we need a PR.

arm-linux-gnueabihf-g++: error: armv7l: No such file or directory
arm-linux-gnueabihf-gcc: error: armv7l: No such file or directory

Yes, it belongs to mess in makefile or in /targets/rpi_makefile.inc

Some points. I build TF lite for custom ARM board, so i use armel, not armhf. Here are my Makefile - https://yadi.sk/d/KDQHxzSb-y5u5Q

PS: don’t forget to run make clean after you change makefile!

@PeterVanNostrand … Good that you can build it. But I am trying for aarch64 architecture, and there is no script for that in 1.13 branch. 😞

@T-Troll … After making the changes you have suggested, i am facing the issue

aarch64-linux-gnu-gcc: error: armv8-a: No such file or directory
<builtin>: recipe for target 'tensorflow/lite/c/c_api_internal.o' failed

and when i checked with ./build_rpi_lib.sh, a similar error occured:

arm-linux-gnueabihf-gcc: error: armv7l: No such file or directory
arm-linux-gnueabihf-g++: error: armv7l: No such file or directory
<builtin>: recipe for target 'tensorflow/lite/c/c_api_internal.o' failed

Probably i am doing something wrong when editing the Makefile as you suggested. Can you please provide the working Makefile via a gist or something .?!

Many Thanks in advance …! 😃