一、交叉编译环境安装
sudo apt-get install gcc-5-powerpc64le-linux-gnu
sudo apt-get install g++-5-powerpc64le-linux-gnu
sudo apt-get install g++-5-multilib-powerpc64le-linux-gnu
二、修改powerpc交叉编译cmakelist
重点:1、设置CMAKE_CXX_COMPILER 并指定为一中安装的交叉编译器;本次代码为cpp,所以选者g++
2、在CMAKE_CXX_FLAGS 中加入-std=c++11 -fpic -O3 -mcpu=power8 -mtune=power8 -DCV_CPU_HAS_SUPPORT_VSX -flto -ffast-math -ftree-vectorize -fpeel-loops -fvect-cost-model -mcmodel=medium -frecord-gcc-switches
powerpc 下示例:
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_CXX_COMPILER "/usr/bin/powerpc64le-linux-gnu-g++-5")
set(CMAKE_CXX_FLAGS "-std=c++11 -fpic -O3 -mcpu=power8 -mtune=power8 -DCV_CPU_HAS_SUPPORT_VSX -flto -ffast-math -ftree-vectorize -fpeel-loops -fvect-cost-model -mcmodel=medium -frecord-gcc-switches" CACHE string "cxx flags" FORCE)
x86下示例为:
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_CXX_COMPILER "/usr/bin/g++")
set(CMAKE_CXX_FLAGS "-std=c++11 -fpic -O3 ${CMAKE_CXX_FLAGS}")
set(OPENCV_ROOT /data/soft/opencv-3.2.0/build/install)
#opencv头文件
include_directories("/data_2/code/public/include")
link_directories(${OPENCV_ROOT}/lib)