链接器错误未定义符号
Linker Error undefined symbols C++
我一直从链接器错误中得到很多麻烦。这是我最近买的一张。
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)
当我添加哈希表(.h和.cpp)时,我得到它。我真的不知道是什么原因导致这个错误。
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;
}
}
}
看起来您添加到您的项目hash.h
和hash.cpp
,但该模块取决于另一个,可能是xmlobject.h
和xmlobject.cpp
。
解决方案:将这些文件也添加到项目中。
相关文章:
- vscode g++链路故障:体系结构x86_64的未定义符号
- 在 Mac 上使用 CMAKE 将 FFTW 和 FFTWPP 链接到项目中时未定义的符号
- 在C++中使用内联方法时出现未定义的符号错误
- 引擎节点:未定义的符号:_ZTV6Config
- 未定义的引用,尽管存在符号,但 std::experimental::可选
- 体系结构x86_64的未定义符号:std:terminate(),typeinfo,运算符delete[],运算符new
- Windows 链接器是否使用 LoadLibrary 解析 DLL 中未定义的符号?
- C++ 中 dlsym 的未定义符号
- MacOS 上的 Xcode 11 项目不在一个函数中使用 sin 和 cos:未定义的符号"___sincosf_stret"
- 仅在 MacOS 上析构函数的未定义符号
- OSX clang++:用于 cpp 文件中显式实例化模板的体系结构x86_64的未定义符号
- PCL 出错:体系结构x86_64 @pcl的未定义符号
- clang:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用) - 体系结构的未定义符号 x86_64:
- 从 C++ 到 Python 的 SWIG:未定义的符号导入问题
- 使用静态变量未解析的外部符号/未定义的引用时出错
- 无法导出mexfunction:符号未定义的collect.exe2.exe:错误:ld返回1退出状态
- 模板生成错误:体系结构的符号未定义 x86_64:
- 继承-符号未定义
- __next_prime符号未定义
- 错误:对cv:: videoccapture::~ videoccapture()的引用符号未定义,命令行中缺少DSO