cmake编译jsonbox错误"TARGETS given no LIBRARY DESTINATION for shared library target"

交叉编译c++的json处理库jsonbox

对于json格式的数据大家应该最熟悉不过了,在写c++程序的时候遇到json数据的解析如果你是大神可以自己手撸一个解析库,大部分时候我选择第三方库,jsoncpp,jsonbox都是不错的选择,这里我选择jsonbox进行移植,需要注意的一点是jsonbox不支持long型数据解析,使用getInteger()会导致数据溢出,而高版本的jsoncpp可以用asLong()获取long型数据。

1.下载源码

https://github.com/anhero/JsonBox

2.交叉编译

先安装cmake:sudo apt-get install cmake-qt-gui
1)配置好源码和安装路径并设置好交叉编译器路径
cmake设置交叉编译器不会的同学看这里:https://blog.csdn.net/haohaohaihuai/article/details/103687671
在这里插入图片描述
按照默认的cmake配置生成的.a静态库,这里需要生成动态库,修改CMakeLists.txt为add_library(JsonBox SHARED ${JSONBOX_SOURCES} ${JSONBOX_HEADERS})
编译以后出现错误==“TARGETS given no LIBRARY DESTINATION for shared library target”==
从字面意思看是没用指定共享库的目标路径,打开CMakeLists.txt发现有一项为install,添加LIBRARY DESTINATION "lib"到install项,保存。
在这里插入图片描述

2)重新make,这回编译通过了

3.安装

make install
在指定的安装目录下成功生成了libJsonbox.so

作者:费码程序猿
欢迎技术交流:QQ:255895056
转载请注明出处

Log data follows: | DEBUG: Executing shell function do_configure | CMake Warning at CMakeLists.txt:7 (message): | Build type not set, falling back to Release mode. | | To specify build type use: | -DCMAKE_BUILD_TYPE=<mode> where <mode> is Debug or Release. | | | -- Building without demo. To enable demo build use: -DWITH_DEMO=True | -- The C compiler identification is GNU 7.3.0 | -- The CXX compiler identification is GNU 7.3.0 | -- Check for working C compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-gcc | -- Check for working C compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-gcc -- works | -- Detecting C compiler ABI info | -- Detecting C compiler ABI info - done | -- Detecting C compile features | -- Detecting C compile features - done | -- Check for working CXX compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-g++ | -- Check for working CXX compiler: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/aarch64-niic-linux/aarch64-niic-linux-g++ -- works | -- Detecting CXX compiler ABI info | -- Detecting CXX compiler ABI info - done | -- Detecting CXX compile features | -- Detecting CXX compile features - done | -- Found PkgConfig: /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/recipe-sysroot-native/usr/bin/pkg-config (found version "0.29.2") | -- Checking for module 'uuid' | -- Found uuid, version 2.32.1 | -- Output libraries to /home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/git/runtime/Cpp/dist | CMake Error at runtime/CMakeLists.txt:104 (install): | install TARGETS given no LIBRARY DESTINATION for shared library target | "antlr4_shared". | | | CMake Error at runtime/CMakeLists.txt:107 (install): | install TARGETS given no ARCHIVE DESTINATION for static library target | "antlr4_static". | | | -- Configuring incomplete, errors occurred! | See also "/home/wu/test_D9/D9_PTG1.5/build-d9/tmp/work/aarch64-niic-linux/antlr4/4.7.2-r0/build/CMakeFiles/CMakeOutput.log".这是报错的log,如何解决这个问题
07-11
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值