在ubuntu14.06编译ARMNN时遇到的关于TensorFlow Lite的问题

编译TensorFlow Lite时我们只需要交叉编译静态库libflatbuffers.a即可,后面提示的这些可以忽略,不影响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

下载TensorFlow Lite

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

在编译TensorFlow Lite时根据自己的情况配置CMAKE

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

或者写编译的全路径

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

此时如果直接make会在编译armnn时提示recompile with -fPIC的错误

[ 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

需要在flatbuffers目录下的CMakeLists.txt添加一句话,这样使用libflatbuffers.a库时就不用指定特定路径了

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

或者把后面的选项也加上

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

之后就可以编译处libflatbuffers.a
再次编译armnn就会顺利通过,整个环境搭建可以参考官网教程
或者我的教程
有错误请指正,欢迎大家交流

猜你喜欢

转载自blog.csdn.net/coinv2014/article/details/102656847
今日推荐