Problems with TensorFlow Lite encountered when compiling ARMNN on ubuntu14.06

When compiling TensorFlow Lite, we only need to cross-compile the static library libflatbuffers.a. The following hints can be ignored and will not affect the compilation of ARMNN

 Generating samples/monster_generated.h
./flatc: 1: ./flatc: Syntax error: word unexpected (expecting ")")
make[2]: *** [samples/monster_generated.h] 错误 2
make[1]: *** [CMakeFiles/flatsamplebinary.dir/all] 错误 2

Download TensorFlow Lite

git clone https://github.com/google/flatbuffers.git
cd flatbuffers

Configure CMAKE according to your own situation when compiling TensorFlow Lite

CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++  cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release

Or write the full path of the compilation

CC=/home/tronlong/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/home/tronlong/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++  cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release

At this time, if you directly make make, it will prompt the error of recompile with -fPIC when compiling armnn

[ 67%] Linking CXX shared library ../../libarmnnTfLiteParser.so
/home/tronlong/gcc-linaro-5.3-2016.02-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.3.1/../../../../arm-linux-gnueabihf/bin/ld: /home/armnn/flatbuffers/libflatbuffers.a(util.cpp.o): relocation R_ARM_THM_MOVW_ABS_NC against `_ZTTSt14basic_ifstreamIcSt11char_traitsIcEE' can not be used when making a shared object; recompile with -fPIC
/home/armnn/flatbuffers/libflatbuffers.a: error adding symbols: 错误的值
collect2: error: ld returned 1 exit status
make[2]: *** [libarmnnTfLiteParser.so] 错误 1
make[1]: *** [src/armnnTfLiteParser/CMakeFiles/armnnTfLiteParser.dir/all] 错误 2
make: *** [all] 错误 2

You need to add a sentence to CMakeLists.txt in the flatbuffers directory, so that you don’t need to specify a specific path when using the libflatbuffers.a library

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC ")

Or add the following options

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -Wall  -Wno-unused-variable -Wold-style-cast -Wno-missing-braces -pthread")

After that, you can compile libflatbuffers.a
and compile armnn again, and it will pass smoothly. For the entire environment, please refer to the official website tutorial
or my tutorial
. Please correct me if there are errors. Welcome to communicate.

Guess you like

Origin blog.csdn.net/coinv2014/article/details/102656847