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

发布于 2024-10-10 13:42:47 字数 169 浏览 10 评论 0原文

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

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

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.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

愿与i 2024-10-17 13:42:47

这就是我所做的:

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 似乎不会自行安装,因此当您构建使用该库的应用程序时,您必须手动将库和头文件复制到您想要的任何位置。

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.

故乡的云 2024-10-17 13:42:47

现在使用 cmake 很容易做到:

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

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

It is now pretty easy to do using cmake:

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

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
心在旅行 2024-10-17 13:42:47

CMAKE 解决方案现在也已弃用。 此处提供了当前的构建解决方案,

cd jsoncpp-master/
BUILD_TYPE=release
#plain, debug, debugoptimized, release, minsize
LIB_TYPE=shared
#LIB_TYPE=static
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . 
build-${LIB_TYPE}
ninja -v -C build-${LIB_TYPE} test

对于新手,给出了一个简单的测试示例此处

The CMAKE solution is also deprecated now. The current build solution is provided here

cd jsoncpp-master/
BUILD_TYPE=release
#plain, debug, debugoptimized, release, minsize
LIB_TYPE=shared
#LIB_TYPE=static
meson --buildtype ${BUILD_TYPE} --default-library ${LIB_TYPE} . 
build-${LIB_TYPE}
ninja -v -C build-${LIB_TYPE} test

And for newbies, a simple test example is given here.

马蹄踏│碎落叶 2024-10-17 13:42:47

使用介子对我来说不起作用。使用 vcpkg 的推荐方法确实有效:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install jsoncpp

来源

Using meson did not work for me. The recommended way of using vcpkg did work:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install jsoncpp

source

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文