进入源码目录,新建build目录用于存放工作文件。依次执行如下命令: Host# cd opencv-2.4.11 Host# mkdir build Host# cd build
在build目录下,新建配置文件arm-linux-gnueabihf.cmake。
n 如使用V01.00.00.03版本Linux Processor-SDK,请写入如下内容:
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
# which C and C++ compiler to use
SET(CMAKE_C_COMPILER/home/tronlong/ti-processor-sdk-linux-am437x-evm-01.00.00.03/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /home/tronlong/ti-processor-sdk-linux-am437x-evm-01.00.00.03/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-g++)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /home/tronlong/ti-processor-sdk-linux-am437x-evm-01.00.00.03/linux-devkit/sysroots/cortexa9t2hf-vfp-neon-linux-gnueabi/usr/lib)
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
红色内容请修改为对应平台Linux Processor-SDK安装包实际的交叉编译工具链和系统库文件路径。从文档拷贝上述内容时,指令可能会出现换行现象,拷贝时请仔细核对。
执行如下命令安装编译插件: Host#sudo apt-get install cmake
在build目录下执行如下命令进行配置并生成makefile: Host#cmake -DWITH_OPENCL=OFF -DWITH_OPENMP=OFF -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/home/tronlong/AM437x/opencv-2.4.11 -DCMAKE_TOOLCHAIN_FILE=arm-linux-gnueabihf.cmake ..
执行make指令,编译适用于AM437x平台的OpenCV库文件,结果如下图所示: Host# make