Fatal error with jsoncpp while compiling

一世执手 提交于 2019-12-06 04:25:44

Since you're on Ubuntu I went to their package website and found the file list for the package you installed: http://packages.ubuntu.com/trusty/amd64/libjsoncpp-dev/filelist

The first few files make the problem clear:

/usr/include/jsoncpp/json/autolink.h
/usr/include/jsoncpp/json/config.h
/usr/include/jsoncpp/json/features.h
/usr/include/jsoncpp/json/forwards.h
/usr/include/jsoncpp/json/json.h

Since compilers usually look in /usr/include, you need to provide the rest of the path, i.e.:

#include <jsoncpp/json/json.h>

You could also have found this file on your running system after installing the package by running this command:

locate json.h

Or using the dpkg command after installing the package.

And when you link your program, you need to say -ljsoncpp, not -ljson.

another solution:

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