在C ++项目中使用libjson [英] Using libjson in a C++ project

查看:288
本文介绍了在C ++项目中使用libjson的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在C ++项目中使用libjson,文档告诉我只是将libjson的源代码添加到你的项目中,在JSONOptions.h文件中注释JSON_LIBRARY,任何C ++编译器都应该编译它。

I'm trying to use libjson within a C++ project and the docs tell me to just "add libjson's source to your project, comment JSON_LIBRARY in the JSONOptions.h file and any C++ compiler should compile it."

对于C ++来说是新手,所有这一切,我该怎么做(不使用任何IDE)?我应该只是 #include libjson.h文件,它是吗?

Being quite new to C++ and all that, how exactly am I supposed to do that (not using any IDE)? Should I just #include the libjson.h file and that's it? Shouldn't I reference libjson somehow in my call to g++ when compiling my project?

thx提前

推荐答案

您必须:

一,

#include <libjson.h>

,以便访问库提供的函数和数据类型,然后

in order to get access to the functions and data types the library offers, then

二,链接到libjsonz库:

Two, link against the libjsonz library:

g++ -o myprogram myprogram.c -ljson

-ljson 最后,或者你将得到一个链接器错误,从没有版本的GCC。)

(the -ljson flag has to come last or you'll get a linker error with never versions of GCC.)

编辑:如果你需要构建库,你通常有一个配置脚本或Makefile。 了解如何使用

if you need to build the library, you typically have a configure script or a Makefile. See how to use them.

这篇关于在C ++项目中使用libjson的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆