How to create a libJSON library?

时光怂恿深爱的人放手 提交于 2019-12-22 11:04:56

问题


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?


回答1:


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.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/3714743/how-to-create-a-libjson-library

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!