Reputation: 73
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). 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;
}
}
}
Upvotes: 1
Views: 4257
Reputation: 98328
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
.
Solution: add these other files to the project too.
Upvotes: 2