Building JSON Parser Library for C++

Warning! Some information on this page is older than 5 years now. I keep it for reference, but it probably doesn't reflect my current knowledge and beliefs.

# Building JSON Parser Library for C++

21:46
Wed
29
Sep 2010

C++ is a flawed language in many aspects, but one of its biggest problems is how difficult it is to start using some C or C++ library. Because of the lack of binary compatibility, separate version have to be prepared for each operating system, compiler and compiler version. Often a version for my compiler is not accessible (or no binary distributions are accessible at all) and I have to compile the library from source code, which always causes problems.

I recently wanted to start using JSON as a configuration file format. It's a nice description language that would make a good compromise between XML (which has lots of redundacy, is unreadable and I generally dislike it) and TokDoc (my custom description language). In search for a JSON parser library for C++, I've decided to use json-cpp. And here the story begins...

Json-cpp is distributed only as source code. README file says that I have to use Scons build system to compile it. WTF is this? How many f*** build systems like this are out there?! Well, I've downloaded it. It looks like it uses and requires Python. I have Python 2.6 installed - it should be OK. Scons Windows setup installed it in the Python directory - OK. What now?

Json-cpp readme says about Scons: "Unzip it in the directory where you found this README file. scons.py Should be at the same level as README.". Unzip?! OK, so maybe I should download the ZIP distribution of Scons instead of setup. I did it, enter the ZIP archive and... There is no scons.py file there! Only scons.1 and some other mysterious files. The only Python script in the main directory is setup.py. So desipte what json-cpp README says, scons cannot be just unzipped, it has to be setup somehow. ARGH!

Luckily this time the solution turned out to be easy. There is a Visual C++ solution file in build\vs71 subdirectory. I managed to successfully convert it to Visual C++ 2008 version and compile it to static LIB files. I only had to ensure that the Runtime Library in Project Options is set to same type as in all my projects, that is the DLL version.

Comments | #c++ #libraries Share

Comments

STAT NO AD
[Stat] [STAT NO AD] [Download] [Dropbox] [pub] [Mirror]
Copyright © 2004-2017