目标:编译生成在RK3036(ARM)平台的
Linux
上可以运行NE10的库
参考:$NE10PATH/doc/Building.md(我们这种应用属于CROSS-COMPILING)
1. 下载projectne10源代码
2. 编译projectne10库
首先确保Vivado2015.4已成功安装
1) 下载neo工程压缩包并解压。
2) 设置gcc编译环境。修改$NE10PATH下的GNUlinux_config.cmake
set(GNULINUX_PLATFORM ON)
if(NOT DEFINED ENV{NE10_LINUX_TARGET_ARCH})
set(NE10_LINUX_TARGET_ARCH "armv7")
else()
set(NE10_LINUX_TARGET_ARCH $ENV{NE10_LINUX_TARGET_ARCH})
endif()
if(NE10_LINUX_TARGET_ARCH STREQUAL "armv7")
set(CMAKE_C_COMPILER arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-linux-gnueabihf-g++)
set(CMAKE_ASM_COMPILER arm-linux-gnueabihf-as)
find_program(CMAKE_AR NAMES "arm-linux-gnueabihf-ar")
find_program(CMAKE_RANLIB NAMES "arm-linux-gnueabihf-ranlib")
elseif(NE10_LINUX_TARGET_ARCH STREQUAL "aarch64")
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_ASM_COMPILER aarch64-linux-gnu-as)
find_program(CMAKE_AR NAMES "aarch64-linux-gnu-ar")
find_program(CMAKE_RANLIB NAMES "aarch64-linux-gnu-ranlib")
endif()
mark_as_advanced(CMAKE_AR)
mark_as_advanced(CMAKE_RANLIB)
由于RK3036为armv7,所以这里只要将armv7条件下的gcc工具链设置修改为RK平台编译环境使用的gcc即可,修改后内容如下:
set(GNULINUX_PLATFORM ON)
if(NOT DEFINED ENV{NE10_LINUX_TARGET_ARCH})
set(NE10_LINUX_TARGET_ARCH "armv7")
else()
set(NE10_LINUX_TARGET_ARCH $ENV{NE10_LINUX_TARGET_ARCH})
endif()
if(NE10_LINUX_TARGET_ARCH STREQUAL "armv7")
set(CMAKE_C_COMPILER arm-rockchip-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER arm-rockchip-linux-gnueabihf-g++)
set(CMAKE_ASM_COMPILER arm-rockchip-linux-gnueabihf-as)
find_program(CMAKE_AR NAMES "arm-rockchip-linux-gnueabihf-ar")
find_program(CMAKE_RANLIB NAMES "arm-rockchip-linux-gnueabihf-ranlib")
elseif(NE10_LINUX_TARGET_ARCH STREQUAL "aarch64")
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_ASM_COMPILER aarch64-linux-gnu-as)
find_program(CMAKE_AR NAMES "aarch64-linux-gnu-ar")
find_program(CMAKE_RANLIB NAMES "aarch64-linux-gnu-ranlib")
endif()
mark_as_advanced(CMAKE_AR)
mark_as_advanced(CMAKE_RANLIB)
3) 执行编译。参照$NE10PATH/doc/Building.md说明,由于我们这种应用属于CROSS-COMPILING,确定编译命令如下:
```bash
cd $NE10_PATH
mkdir build && cd build
export NE10_LINUX_TARGET_ARCH=armv7 # Can also be "aarch64"
cmake -DCMAKE_TOOLCHAIN_FILE=../GNUlinux_config.cmake ..
make
```
4) 编译结果。 我们可以得到./modules/libNE10.a(库文件)、./samples/NE10_test_static(测试程序)
5) 编译动态库。只要修改cmake命令,加入-DNE10_BUILD_SHARED=ON
即可。
cmake -DCMAKE_TOOLCHAIN_FILE=../GNUlinux_config.cmake -DNE10_BUILD_SHARED=ON ..
转载:
参考: