使用JsonBox getObject的未定义引用

时间:2018-03-01 22:53:46

标签: c++ xcode c++11

我正在处理有关项目部分的本教程。 http://www.penguinprogrammer.co.uk/rpg-tutorial/items/

我的item.cpp代码如下所示

#include "item.hpp"
#include "entity.hpp"
#include "JsonBox.h"
#include "entitymanager.hpp"

Item::Item(std::string id, std::string name, std::string description) : Entity(id) {
    this->name = name;
    this->description = description;
}

Item::Item(std::string id, JsonBox::Value& val, EntityManager* mgr) : Entity(id) {
    this->Load(val, mgr);
}

void Item::Load(JsonBox::Value& val, EntityManager* mgr) {
    JsonBox::Object obj = val.getObject();
//    this->name = obj["name"].getString();
//    this->description = obj["description"].getString();
}

并且收到此错误

Undefined symbols for architecture x86_64:
  "JsonBox::Value::Value(JsonBox::Value const&)", referenced from:
      std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, JsonBox::Value>::pair(std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, JsonBox::Value> const&) in item.o
  "JsonBox::Value::~Value()", referenced from:
      std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, JsonBox::Value>::~pair() in item.o
  "JsonBox::Value::getObject() const", referenced from:
      Item::Load(JsonBox::Value&, EntityManager*) in item.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

如何修复链接器?

作为参考,JsonBox库在这里https://github.com/anhero/JsonBox 教程回购在这里https://github.com/dbMansfield/cpp-rpg-tutorial

0 个答案:

没有答案
相关问题