3

I downloaded C++ libJSON from this link:

And they suggest me to use it as a library. How can I create library using the code they have provided?

Community
  • 1
  • 1
RK-
  • 12,099
  • 23
  • 89
  • 155

3 Answers3

4

i was trying to compile libjson 7.6.1 for Visual Studio 2010. And was facing some difficulties in compiling it. What i did was

  1. Download Libjson
  2. open libjson.vcproj and goto line 240. You will find a missing ">". Type it in and save the file.
  3. Now this can be used to build dynamic and static lib.

A simple thing wasted my couple of hours. Hope it saves some of yours.

Anunay
  • 1,823
  • 2
  • 18
  • 25
4

you must have installed g++ and make in console/terminal just compile it type make, it will produce libjson.a which is static libary. When you create you C/C++ program you can link it with it g++ -l libjson.a

and in your code include libJSON.h header file.

#include "libJSON.h"

and you can use all functions from that header file.

On windows you must Install MinGW (GNU utilities for Windows), or IDE like DevC++ or Code::Blocks (Code::Blocks use MinGW). You can also use Cygwin unix like environment for windows (but when you compile file in cygwin you can run it only in Cygwin)

In Code::Blocks when you create project you can set additinal library which will be linked with your executable.

jcubic
  • 61,973
  • 54
  • 229
  • 402
  • can you detail the steps to create lib file? – RK- Sep 16 '10 at 09:06
  • This worked in MAc. Can you guide me how to do it in Windows? – RK- Sep 16 '10 at 09:27
  • "it will produce libjson.a which is shared libary" -- libjson.a is a static archive, not a shared library. To make the shared library (which is an ".so" file), you must use `SHARED=1 make` – kylehuff Apr 26 '15 at 16:35
0

This solution also works for more recent versions of Visual studio (e.g. 2015) which otherwise fail to complete the conversion to the mare recent project format.

Phil Rosenberg
  • 1,597
  • 1
  • 14
  • 22