[英]Linker Error undefined symbols C++
I have been getting a lot of trouble from linker errors. 链接器错误给我带来了很多麻烦。 This is the most recent one I have gotten.
这是我最近得到的。
Undefined symbols for architecture x86_64:
"XMLObject::~XMLObject()", referenced from:
Hash::addFile(char*, XMLObject) in hash.o
std::__1::__split_buffer<XMLObject, std::__1::allocator<XMLObject>&>::~__split_buffer() in hash.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I get it when i add a hash table (.h and .cpp). 我在添加哈希表(.h和.cpp)时得到了它。 I really dont know what could cause this error.
我真的不知道什么可能导致此错误。
void Hash::addObj(char* id, XMLObject num)
{
int index = hash(id);
if(hashTable[index]->identifier == "empty") // checks empty bucket
{
hashTable[index]->identifier = id;
hashTable[index]->files.push_back(num);
}
else // checks list
{
bool check = false; // true if id word was found
item* ptr = hashTable[index];
while(ptr != nullptr)
{
if(ptr->identifier == id)
{
ptr->files.push_back(num);
check = true;
break;
}
ptr = ptr->next;
}
if(!check)
{
item* n = new item;
n->identifier = id;
n->files.push_back(num);
n->next = nullptr;
ptr = n;
}
}
}
It looks like you added to your project hash.h
and hash.cpp
, but that module depends on another one, maybe xmlobject.h
and xmlobject.cpp
. 看起来您已经添加到项目
hash.h
和hash.cpp
,但是该模块依赖于另一个模块,可能是xmlobject.h
和xmlobject.cpp
。
Solution: add these other files to the project too. 解决方案:也将其他文件添加到项目中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.