Xcode 10.0:链接器命令失败,退出代码为 1(使用 -v 查看调用)
Xcode 10.0: Linker command failed with exit code 1 (use -v to see invocation)
使用以下代码创建了一个新的 Xcode cpp 项目,它给我一个 clang 错误 "Linker command failed with exit code 1"。
我尝试 运行 这是一个现有的 Xcode 项目,它构建成功,但是当我在现有的项目中这样做或创建一个新项目并复制粘贴此代码时,同样的问题。我还尝试研究了有关此错误的其他 Whosebug 帖子,但似乎没有找到解决方案的具体方法。
#include <iostream>
#include <stdio.h>
using namespace std;
class LList{
private:
//Represents each node in the LL
struct ListNode{
int data;
ListNode* next;
};
typedef struct ListNode* nodePtr;
nodePtr head, current, temp;
public:
LList();
void Insert(int addData) {
nodePtr n = new ListNode;
n->next = NULL;
n->data = addData;
if(head != NULL){
current = head;
while(current->next != NULL){
current = current->next;
}
current->next = n;
}
else{
head = n;
}
};
void Remove(int removeData) {
nodePtr delPtr = NULL;
temp = head;
current = head;
while(current != NULL && current->data != removeData){
temp = current;
current = current->next;
}
if(current == NULL){
cout << removeData << " was not in the list\n";
delete delPtr;
}
else{
delPtr = current;
current = current->next;
temp->next = current;
if(delPtr == head){
head = head->next;
temp = NULL;
}
delete delPtr;
cout << "The value " << removeData << " was deleted\n";
}
};
void PrintList() {
current = head;
while(current != NULL){
cout << current->data << " - ";
current = current->next;
}
cout << "\n";
};
LList::ListNode* middleNode(LList::ListNode* head) {
LList::ListNode* fastPtr = head;
LList::ListNode* slowPtr = head;
while(fastPtr->next != NULL){
fastPtr = fastPtr->next;
if(fastPtr->next != NULL){
fastPtr = fastPtr->next;
}
slowPtr = slowPtr->next;
}
return slowPtr;
};
};
int main() {
LList Aj;
Aj.Insert(5);
Aj.Insert(8);
Aj.Insert(10);
Aj.PrintList();
Aj.Remove(8);
Aj.PrintList();
Aj.Remove(5);
Aj.PrintList();
}
LList()
默认构造函数已声明,但从未实现。
使用以下代码创建了一个新的 Xcode cpp 项目,它给我一个 clang 错误 "Linker command failed with exit code 1"。
我尝试 运行 这是一个现有的 Xcode 项目,它构建成功,但是当我在现有的项目中这样做或创建一个新项目并复制粘贴此代码时,同样的问题。我还尝试研究了有关此错误的其他 Whosebug 帖子,但似乎没有找到解决方案的具体方法。
#include <iostream>
#include <stdio.h>
using namespace std;
class LList{
private:
//Represents each node in the LL
struct ListNode{
int data;
ListNode* next;
};
typedef struct ListNode* nodePtr;
nodePtr head, current, temp;
public:
LList();
void Insert(int addData) {
nodePtr n = new ListNode;
n->next = NULL;
n->data = addData;
if(head != NULL){
current = head;
while(current->next != NULL){
current = current->next;
}
current->next = n;
}
else{
head = n;
}
};
void Remove(int removeData) {
nodePtr delPtr = NULL;
temp = head;
current = head;
while(current != NULL && current->data != removeData){
temp = current;
current = current->next;
}
if(current == NULL){
cout << removeData << " was not in the list\n";
delete delPtr;
}
else{
delPtr = current;
current = current->next;
temp->next = current;
if(delPtr == head){
head = head->next;
temp = NULL;
}
delete delPtr;
cout << "The value " << removeData << " was deleted\n";
}
};
void PrintList() {
current = head;
while(current != NULL){
cout << current->data << " - ";
current = current->next;
}
cout << "\n";
};
LList::ListNode* middleNode(LList::ListNode* head) {
LList::ListNode* fastPtr = head;
LList::ListNode* slowPtr = head;
while(fastPtr->next != NULL){
fastPtr = fastPtr->next;
if(fastPtr->next != NULL){
fastPtr = fastPtr->next;
}
slowPtr = slowPtr->next;
}
return slowPtr;
};
};
int main() {
LList Aj;
Aj.Insert(5);
Aj.Insert(8);
Aj.Insert(10);
Aj.PrintList();
Aj.Remove(8);
Aj.PrintList();
Aj.Remove(5);
Aj.PrintList();
}
LList()
默认构造函数已声明,但从未实现。