源码获取
地址1:sourceforge.net
版本说明:比较旧的0.5.0版本,使用configure配置文件进行编译;
地址2:github.com
版本说明:包含其他历史版本,但通常下载的版本是0.10.x ,使用cmake编译,编译过程比较麻烦。
交叉编译
1.安装交叉编译工具链,并添加路径到PATH
2.编写配置文件toolchain.cmake
# this one is important SET(CMAKE_SYSTEM_NAME Linux) #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) # where is the target environment SET(CMAKE_FIND_ROOT_PATH /usr/local/arm-linux-gnueabihf-6.3) # 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)
3.执行cmake指令,指定相关编译参数(编译类型,生成动态库,安装路径,配置文件)
cmake -DCMAKE_BUILD_TYPE=release -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=~/tmp/jsoncpp-0.10.7/build/orejia-install -DCMAKE_TOOLCHAIN_FILE=~/tmp/jsoncpp-0.10.7/toolchain.cmake ..
4.make
make && make install