JsonBox函数的未定义引用

铁匠

我正在尝试遵循企鹅程序员基于文本的rpg指南(http://www.penguinprogrammer.co.uk/rpg-tutorial/introduction/)。我正在处理item类,并且JsonBox函数存在一些未定义的引用错误。

#include "Item.hpp"
#include "Entity.hpp"
#include "JsonBox/include/JsonBox.h"
//#include "EntityManager.hpp"

Item::
Item(std::string _id, std::string _name, std::string _description)
  : Entity(_id) {
  this->SetName(_name);
  this->SetDescription(_description);
}

Item::
Item(std::string _id, JsonBox::Value& _v, EntityManager* _mgr)
  : Entity (_id) {
  this->Load(_v, _mgr);
}

void
Item::
Load(JsonBox::Value& _v, EntityManager* _mgr) {
  JsonBox::Object o = _v.getObject();
  this->SetName(o["name"].getString());
  this->SetDescription(o["description"].getString());

  return;
}

然后,我正在编译这个主程序。

//#include "EntityManager.cpp"
#include "Item.cpp"
#include "JsonBox/include/JsonBox.h"

int main() {

  return 0;
}

并得到这个错误

/tmp/cc1sZXwe.o: In function `Item::Load(JsonBox::Value&, EntityManager*)':
main.cpp:(.text+0x286): undefined reference to `JsonBox::Value::getObject()        const'
main.cpp:(.text+0x2d4): undefined reference to `JsonBox::Value::getString()   const'
main.cpp:(.text+0x35c): undefined reference to `JsonBox::Value::getString()    const'
/tmp/cc1sZXwe.o: In function `std::pair<std::string const,     JsonBox::Value>::~pair()':
main.cpp:      (.text._ZNSt4pairIKSsN7JsonBox5ValueEED2Ev[_ZNSt4pairIKSsN7JsonBox5ValueEED5Ev]+    0x18): undefined reference to `JsonBox::Value::~Value()'
/tmp/cc1sZXwe.o: In function `std::pair<std::string const,     JsonBox::Value>::pair(std::pair<std::string const, JsonBox::Value> const&)':
main.cpp:    (.text._ZNSt4pairIKSsN7JsonBox5ValueEEC2ERKS3_[_ZNSt4pairIKSsN7JsonBox5ValueEEC5    ERKS3_]+0x3b): undefined reference to `JsonBox::Value::Value(JsonBox::Value     const&)'
/tmp/cc1sZXwe.o: In function `std::pair<std::string const,     JsonBox::Value>::pair<std::string&&, 0ul>(std::tuple<std::string&&>&,   std::tuple<>&, std::_Index_tuple<0ul>, std::_Index_tuple<>)':
main.cpp: (.text._ZNSt4pairIKSsN7JsonBox5ValueEEC2IIOSsEILm0EEIEIEEERSt5tupleIIDpT_EERS6_I IDpT1_EESt12_Index_tupleIIXspT0_EEESF_IIXspT2_EEE[_ZNSt4pairIKSsN7JsonBox5ValueE EC5IIOSsEILm0EEIEIEEERSt5tupleIIDpT_EERS6_IIDpT1_EESt12_Index_tupleIIXspT0_EEESF _IIXspT2_EEE]+0x47): undefined reference to `JsonBox::Value::Value()'
聚苯硫醚

在其中main包含Item.cpp源文件的情况下,将其更改main为以下内容可能会帮助您:

//#include "EntityManager.cpp"
#include "Item.hpp"
#include "JsonBox/include/JsonBox.h"

int main() {

    return 0;
}

包含源文件通常是一种不好的做法,并且可能导致许多问题,您可以阅读有关包含.cpp文件的更多信息。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

对定义的构造函数的“未定义引用”

来自分类Dev

对定义的构造函数的“未定义引用”

来自分类Dev

对已定义函数的未定义引用

来自分类Dev

未定义对函数调用的引用?

来自分类Dev

未定义对函数send的引用

来自分类Dev

未定义对swscale函数的引用

来自分类Dev

未定义对'gnutls _...'函数的引用

来自分类Dev

未定义对模板成员函数的引用

来自分类Dev

未定义对某些opencv函数的引用

来自分类Dev

未定义的函数错误引用

来自分类Dev

构造函数中的未定义引用

来自分类Dev

未定义对继承函数的引用

来自分类Dev

未定义对Aruco函数的引用

来自分类Dev

未定义对函数的引用?C ++

来自分类Dev

未定义对cusolverDn函数的引用

来自分类Dev

gcc对portaudio函数的未定义引用

来自分类Dev

C ++:对构造函数的未定义引用

来自分类Dev

未定义对静态函数的引用

来自分类Dev

在main()中未定义对函数的引用

来自分类Dev

未定义对函数c的引用

来自分类Dev

未定义对Makefile中的“函数”的引用

来自分类Dev

引用错误:函数未定义

来自分类Dev

未定义对自写函数的引用

来自分类Dev

未定义对espeak函数的引用

来自分类Dev

未定义的函数引用(C ++)

来自分类Dev

C ++:对void函数的未定义引用

来自分类Dev

对C ++中函数的未定义引用

来自分类Dev

对C ++中函数的未定义引用

来自分类Dev

对我的函数的未定义引用