无法在C ++中嵌入XCode 4项目中安装libjson [英] Cannot Install libjson in c++ Embedding in XCode 4 Project

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

问题描述

我根本不知道如何将libjson安装为我的c ++项目的一部分。我已经通过一切在线。嵌入在我的项目。

I simply cannot figure out how to get libjson installed as part of my c++ project. I've been through everything online. Am embedding this in my project.

首先我尝试了


  1. 将libjson目录移动到我的项目

  2. 已注释掉:#define JSON_LIBRARY

  3. 换行

  4. 添加#includelibjson / libjson.h

Project builds ok ..

Project builds ok..

file:

JSONNode n = libjson::parse(json);

构建失败,出现两个错误:

Build fails with two errors:

Undefined symbols for architecture x86_64:
  "JSONWorker::parse(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)", referenced from:
      libjson::parse(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in main.o
  "internalJSONNode::deleteInternal(internalJSONNode*)", referenced from:
      JSONNode::decRef()     in main.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status

我也试过make& sudo make手动安装和编译项目。相同的错误:

I've also tried make && sudo make install and compiling the project manually. Same errors:

g++ main.cpp -o junk -I/usr/include/libjson -ljson

我也尝试过:

SHARED=1 make && sudo SHARED=1 prefix=/usr/local make install

最后,我试过复制libjson文件到我的项目,也得到相同的错误。

Finally, I've tried copying the libjson file into my project and also get the same errors.

有人可以告诉我我做错了什么?我们使用rapidjson,但更喜欢libjson的外观。主要问题是我们无法安装它!

Please can someone show me what I'm doing wrong? We were using rapidjson but prefer the look of libjson. The major problem is that we cannot install it!

其他参考文献:

  • Using libjson in a C++ project
  • http://sourceforge.net/p/libjson/discussion/1119662/thread/2e0774a7

推荐答案

我回答自己的问题,因为这是一个痛苦颈部。

I'm answering my own question because this was a pain in the neck. Here's what I did to get it working.


  1. 在JSONOptions.h中注释#define JSON_LIBRARY

  2. 运行make

  3. 将libjson.a添加到您的项目

  4. 将JSONOptions.h添加到您的项目

  5. 将#includelibjson.h添加到您的主项目文件中

  1. Comment out #define JSON_LIBRARY in JSONOptions.h
  2. Run make
  3. Add libjson.a to your project
  4. Add libjson.h to your project
  5. Add JSONOptions.h to your project
  6. Add #include "libjson.h" to your main project file


$ b b 。希望你不浪费我这么多的时间...

Voila. Hope you don't waste as much time as I did on this...

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

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