- 修改arm_make.cmake文件
修改后的文件内容:
# CMake toolchain file for building ARM software on OI environment
include(CMakeForceCompiler)
# this one is important
SET(CMAKE_SYSTEM_NAME Linux)
set( CMAKE_SYSTEM_PROCESSOR arm )
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)
# specify the cross compiler
SET(CMAKE_C_COMPILER **arm-linux-gnueabihf-**gcc)
SET(CMAKE_CXX_COMPILER **arm-linux-gnueabihf-**g++)
SET(CMAKE_STRIP **arm-linux-gnueabihf-**strip)
CMAKE_FORCE_C_COMPILER(**arm-linux-gnueabihf-**gcc GNU)
CMAKE_FORCE_CXX_COMPILER(**arm-linux-gnueabihf-**g++ GNU)
#SET(CMAKE_C_COMPILER gcc)
#SET(CMAKE_CXX_COMPILER g++)
#SET(CMAKE_STRIP strip)
# where is the target environment
#SET(CMAKE_FIND_ROOT_PATH "/mnt/hgfs/Share/cmake project/libvznet")
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
- 编写编译脚本
- 创建 build目录,
mkdir build
cd build
- 创建 mk.sh,
vim mk.sh
,输入内容
- 创建 build目录,
#!/bin/bash
CC=/home/zwq/cross_tool/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc CXX=/home/zwq/cross_tool/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ cmake .. -DJSONCPP_WITH_TESTS=OFF -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF -DENABLE_UNIT_TEST=OFF
make
注意:其中 CC=、CXX=改成自己的交叉编译器
- 编译SDK
./mk.sh
- 编译输出文件
1. 库文件路径lib/unix/libvztcpsdk_dynamic.so
2. 可执行文件路径bin/unix/sdk_test