LD:架构x86_64 clang找不到符号:错误:链接器命令失败,出口代码1(使用-v to See
ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see
我的第一篇文章之一,很抱歉任何格式错误:
我正在尝试创建一个简单的链接列表类,但是每当我尝试运行代码时,我都会遇到错误。我正在编写的另一个代码也没有共享任何独特的特征。我已经搜索了这个网站和其他论坛,大约一个月了,我找不到任何有助于解决方案的东西。这是错误:
架构X86_64的未定义符号:" linkedlist :: linkedlist()",从: _ Main.o中的MainLD:符号(s)架构x86_64找不到符号clang:错误:Linker命令因出口代码1失败(使用-V查看调用)
很抱歉列出了长时间的代码,但我根本无法缩小问题。这是我的主():
#include <iostream>
#include "LinkedListHeader.h"
using namespace std;
// Driver
int main()
{
// LinkedList instance
LinkedList* obj = new LinkedList();
// Prompt user for number of inputs
int count;
cout << "How many items would you like to add to the list?" << endl;
cin >> count;
// For loop
for (int i = 0; i < count; i++)
{
double value;
cout << "Enter item " << i + 1 << ": ";
cin >> value;
obj->add(value);
}
// Call member function displayList() to... wait for it... display the list
obj->displayList();
// Prompt user for a search criteria
double search;
cout << "Enter a number to search for in the list: ";
cin >> search;
// If value is in the list then tell the user. If it ain't then don't
if(obj->isMember(search))
{
cout << search << " is in the list!" << endl;
}
else
cout << search << " is NOT in the list!" << endl;
return 0;
}
linkedlistheader.h:
class LinkedList
{
public:
// LinkedList constructor
LinkedList();
// ListNode struct --> Linked List
struct ListNode
{
double value;
ListNode *next;
// Constructor
ListNode(double value1, ListNode *next1 = nullptr)
{
value = value1;
next = next1;
}
};
// add(double) adds a node to the list with value x
void add(double x)
{
if(head == nullptr)
{
head = new ListNode(x);
}
else
{
ListNode *nodePtr = head;
while(nodePtr->next != nullptr)
{
nodePtr = nodePtr->next;
}
nodePtr->next = new ListNode(x);
}
}
// isMember(x) trverses through list to determine if (value == x)
bool isMember(double x)
{
ListNode *nodePtr = head;
while(nodePtr->next != nullptr)
{
if (nodePtr->value != x)
{
return true;
}
else
return false;
}
return false;
}
// displayList() prints out each member of the list (used to make sure add(double) was working properly)
void displayList()
{
ListNode *nodePtr = head;
while(nodePtr)
{
std::cout << nodePtr->value << " ";
nodePtr = nodePtr->next;
}
std::cout << std::endl;
}
ListNode *head = nullptr;
};
这是我的日志中的完整错误
,因此错误很简单,您没有编写constortor LinkedList::LinkedList()
,但您确实保证要编写它。
class LinkedList
{
public:
// LinkedList constructor
LinkedList();
您的代码中的链接列表构造函数在哪里?编写构造函数,或删除写信的承诺(我认为您可以做后者)。
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 代码在main()中运行,但在函数中出现错误
- 在VS代码中交叉编译Windows与Linux上的MinGW的SDL程序
- 编译包含字符串的代码时遇到问题
- 我在c++代码中生成了一个运行时#3异常
- 如何在linux终端中同时编译和运行c++代码
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 在Linux for Windows上编译C++代码时出错
- 我的字符计数代码计算错误.为什么
- 孤立代码块在结构中引发异常
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 为什么我的C#代码在调用回C++COM直到Task时会暂停.等待/线程.加入
- 处理小于cpu数据总线的数据类型.(c++转换为机器代码)
- C++ 如何重用具有多个返回(出口点)的代码块?
- 使用清理代码优化多个出口点
- OSX MOJAVE -LD:架构X86_64 clang找不到符号:错误:链接器命令失败,出口代码1
- C 错误链接器命令失败了出口代码1(使用-V查看调用)
- Xcode C :链接命令失败,出口代码1未找到-lboost_regex
- LD:架构x86_64 clang找不到符号:错误:链接器命令失败,出口代码1(使用-v to See
- C /R:clang:错误:Linker命令失败,出口代码1(使用-v查看调用)