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

Question:

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.

Asked By: skyeagle

||

Answers:

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.

Answered By: nos

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
Answered By: aktaylor

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.

Answered By: R71

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

Answered By: whyameye
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.