我一直在尝试为ARM目标系统交叉编译opencv。我的项目依赖于使用opencv 2.4.11。
目标系统是petalinux 2017.2,运行在Zynq Ultrascale + FPGA的四核Cortex A53上。
我的主机系统是Ubuntu 16.04 x86_64。
我使用以下toolchain.cmake文件进行配置:
set( CMAKE_SYSTEM_NAME Linux)
set( CMAKE_SYSTEM_PROCESSOR arm)
set( CMAKE_C_COMPILER /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc)
set( CMAKE_CXX_COMPILER /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/bin/aarch64-linux-gnu-g++)
set( CMAKE_FIND_ROOT_PATH /home/benjaminh/embedded_development/ultrazed_repo/scripts/rootfs_part)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
我执行了以下步骤:
wget https://github.com/Itseez/opencv/archive/2.4.11.zip
unzip 2.4.11.zip
cd opencv-2.4.11
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../
make -j4
正如您所看到的,构建过程失败了:错误:'asm'中的未知寄存器名称'st'。似乎它试图用ARM编译器来解释x86_64库
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gaussmix.cpp.o
[ 44%] Building CXX object modules/photo/CMakeFiles/opencv_photo.dir/src/denoising.cpp.o
In file included from /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/aarch64-linux-gnu/libc/usr/include/math.h:472:0,
from /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/6.2.1/cmath:45,
from /home/benjaminh/petalinux_2017_2/tools/linux-i386/aarch64-linux-gnu/aarch64-linux-gnu/include/c++/6.2.1/math.h:36,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/core/include/opencv2/core/types_c.h:94,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/core/include/opencv2/core/core.hpp:49,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/highgui/include/opencv2/highgui/highgui.hpp:46,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/highgui/src/precomp.hpp:47,
from /home/benjaminh/embedded_development/opencv-2.4.11/modules/highgui/src/cap_images.cpp:52:
/usr/include/x86_64-linux-gnu/bits/mathinline.h: In member function ‘virtual bool CvCapture_Images::setProperty(int, double)’:
/usr/include/x86_64-linux-gnu/bits/mathinline.h:889:3: error: unknown register name ‘st’ in ‘asm’
__lrint_code;
^
/usr/include/x86_64-linux-gnu/bits/mathinline.h:889:3: error: unknown register name ‘st’ in ‘asm’
__lrint_code;
^
modules/highgui/CMakeFiles/opencv_highgui.dir/build.make:86: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_images.cpp.o' failed
make[2]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/src/cap_images.cpp.o] Error 1
CMakeFiles/Makefile2:2275: recipe for target 'modules/highgui/CMakeFiles/opencv_highgui.dir/all' failed
make[1]: *** [modules/highgui/CMakeFiles/opencv_highgui.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/lkpyramid.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/video_init.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gmg.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/tvl1flow.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/bgfg_gaussmix2.cpp.o
[ 44%] Linking CXX shared library ../../lib/libopencv_photo.so
[ 44%] Built target opencv_photo
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/kalman.cpp.o
[ 44%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/simpleflow.cpp.o
[ 44%] Linking CXX shared library ../../lib/libopencv_video.so
[ 44%] Built target opencv_video
Makefile:160
: recipe for target 'all' failed
make: *** [all] Error 2
在构建过程中不时会出现类似这些警告,这表示设置路径有问题:
cc1plus: warning: include location "/usr/include/glib-2.0" is unsafe for cross-compilation [-Wpoison-system-directories]
cc1plus: warning: include location "/usr/include/freetype2" is unsafe for cross-compilation [-Wpoison-system-directories]
cc1plus: warning: include location "/usr/include/x86_64-linux-gnu" is unsafe for cross-compilation [-Wpoison-system-directories]
对我而言,目前尚不清楚它为什么采用主机路径而不是给定的目标根路径。
答案 0 :(得分:1)
您的工具链文件不完整。 petalinux会提供一个吗?
您需要添加指令,以便make在构建目标对象时不会尝试使用host包含:
myTableA
您可能还需要指定目标sys root:
myTableB