C++ compiler errors TFlite
3 views (last 30 days)
Show older comments
Good afternoon,
I have been trying to deploy a tflite model onto my raspberry pi using MATLAB 2024a.
To start i am using:
- Example code (SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample).
- Mex code setup i am using 'Microsoft Visual C++ 2022'
- Built Tensorflow 2.15 on Windows with Bazel 6.10
- Downloaded and setup Raspberry pi Matlab config
- Raspberry pi 32 bit bullseye (python 3.9.2)
- created all of the paths accordingly as stated in Prerequisites for Deep Learning with TensorFlow Lite Models
When i run the code it has no errors. The problem starts once i run:
- codegen -config cfg tflite_semantic_predict -args ones(257,257,3,'single')
The error is as follows:
codegen -config cfg tflite_semantic_predict -args ones(257,257,3,'single')
------------------------------------------------------------------------
Error executing command "touch -c /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/*.*;make -j$(($(nproc)+1)) -Otarget -f tflite_semantic_predict_rtw.mk all MATLAB_WORKSPACE="/home/bmblaylock42/MATLAB_ws/R2024a" LINUX_TARGET_LIBS_MACRO="" -C /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict LC_ALL=C". Details:
STDERR: In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp:6:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:382: invokeinterpreter.cpp.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/model.h:26,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/kernels/register.h:22,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/kernels/register.h:18,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/invokeinterpreter.hpp:16,
from /home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp:15:
/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter/tensorflow/lite/core/interpreter_builder.h:33:10: fatal error: flatbuffers/flatbuffers.h: No such file or directory
33 | #include "flatbuffers/flatbuffers.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [tflite_semantic_predict_rtw.mk:398: tflite_semantic_predict.cpp.o] Error 1
STDOUT: make: Entering directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
g++ -c -MMD -MP -MF"tflite_semantic_predict_data.cpp.dep" -MT"tflite_semantic_predict_data.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_data.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_data.cpp"
make: Leaving directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
make: Entering directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
g++ -c -MMD -MP -MF"tflite_semantic_predict_terminate.cpp.dep" -MT"tflite_semantic_predict_terminate.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_terminate.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_terminate.cpp"
make: Leaving directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
make: Entering directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
g++ -c -MMD -MP -MF"tflite_semantic_predict_initialize.cpp.dep" -MT"tflite_semantic_predict_initialize.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict_initialize.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict_initialize.cpp"
make: Leaving directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
make: Entering directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
g++ -c -MMD -MP -MF"invokeinterpreter.cpp.dep" -MT"invokeinterpreter.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "invokeinterpreter.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/invokeinterpreter.cpp"
make: Leaving directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
make: Entering directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
g++ -c -MMD -MP -MF"tflite_semantic_predict.cpp.dep" -MT"tflite_semantic_predict.cpp.o" -fpermissive -O2 -DMW_NUM_CORES=4 -pthread -fopenmp -std=c++17 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -D__linux__ -DARM_PROJECT -D_USE_TARGET_UDP_ -D_RUNONTARGETHARDWARE_BUILD_ -DSTACK_SIZE=200000 -DMODEL=tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/tflite_interface/invokeinterpreter/export/include/invokeinterpreter -I -I/tensorflow/lite -I/tensorflow/lite/tools/make/downloads/flatbuffers/include -I/flatbuffers/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/ProgramData/MATLAB/SupportPackages/R2024a/toolbox/realtime/targets/raspi/include -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/toolbox/coder/rtiostream/src/utils -I/home/bmblaylock42/MATLAB_ws/R2024a/C/Program_Files/MATLAB/R2024a/extern/include -o "tflite_semantic_predict.cpp.o" "/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict/tflite_semantic_predict.cpp"
make: Leaving directory '/home/bmblaylock42/MATLAB_ws/R2024a/C/Users/BransonBlaylock/SemanticSegmentationUsingTFLiteModelOnHostAndRasPiExample/codegen/lib/tflite_semantic_predict'
------------------------------------------------------------------------
Build error: C++ compiler produced errors. See the Build Log for further details.
More information
Code generation failed: View Error Report
Error using codegen

Thank you so much i have tried to download the flatbuffers by CMake and bazel but i had no luck since they are 64 bit codes and mine is a 32bit aarch64.
0 Comments
Accepted Answer
埃博拉酱
on 27 Jan 2025
You're encountering a very similar issue as another question. Refer to my answer there and see if it helps.
2 Comments
埃博拉酱
on 28 Jan 2025
If you are lacking header files that you cannot find even manually, there are 3 common possibilities:
- Your project relies on some other libraries that you have not installed.
- Some libraries you have downloaded are incomplete or broken.
- The lacking headers are not for your environment. These inclusions should have been excluded by conditional compilation instructions, but actually not excluded, probably because of some options not correctly configured.
My advice is that you search for details of these headers. What they do and where they should work shall hint you which is your case.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!