构建 jsoncpp (Linux) - 对我们凡人的指导?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4628922/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:24:13  来源:igfitidea点击:

building jsoncpp (Linux) - an instruction for us mere mortals?

c++pythonlinuxjsonscons

提问by skyeagle

I am trying to build jsoncpp on Ubuntu 10.x - however the 'instructions' are at times vague. For example, it is not clear exactly which folder the scons.py file needs to reside in before the lib can be built.

我正在尝试在 Ubuntu 10.x 上构建 jsoncpp - 但是“说明”有时含糊不清。例如,在构建 lib 之前,scons.py 文件需要驻留在哪个文件夹中并不清楚。

Can someone outline the steps required to build the jsoncpp library? on Linux, or failing that, if anyone is aware of any online resource with this info, please share the link.

有人可以概述构建 jsoncpp 库所需的步骤吗?在 Linux 上,或者失败了,如果有人知道任何包含此信息的在线资源,请分享链接。

采纳答案by nos

Here's what I did:

这是我所做的:

apt-get install scons
wget "http://downloads.sourceforge.net/project/jsoncpp/jsoncpp/0.5.0/jsoncpp-src-0.5.0.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fjsoncpp%2F&ts=1294425421&use_mirror=freefr"
tar -xvzf jsoncpp-src-0.5.0.tar.gz
cd jsoncpp-src-0.5.0
scons platform=linux-gcc

jsoncpp doesn't seem to install itself, so you'll have to manually copy the library and header files wherever you want them when you're building applications that use the library.

jsoncpp 似乎不会自行安装,因此在构建使用该库的应用程序时,您必须手动将库和头文件复制到您想要的任何位置。

回答by aktaylor

It is now pretty easy to do using cmake:

现在使用 cmake 很容易做到:

Make sure CMake is installed and than in the main repo run the following commands:

确保安装了 CMake,然后在主 repo 中运行以下命令:

mkdir -p build/debug
cd build/debug
cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_STATIC=ON-DJSONCPP_LIB_BUILD_SHARED=OFF -G "Unix Makefiles" ../..
make
make install