【发布时间】:2017-01-02 18:45:54
【问题描述】:
我正在尝试在 QT Creator 中运行这个简单的代码。
#include<iostream>
using namespace std;
const int SENTINEL = 0;
int main() {
cout<<"This program adds a list of numbers "<<endl;
cout<<"Use "<<SENTINEL<<" to signal the end."<<endl;
int total = 0;
while(true) {
int value;
cout<<" ? ";
cin>>value;
if(value == SENTINEL) break;
total += value;
}
cout<<"The total is "<<total<<endl;
return 0;
}
但我不断遇到这两个问题。
错误:未找到 x86_64 架构的符号
错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)
我得到的完整描述是这样的。内部编译输出。
架构 x86_64 的未定义符号:“Main()”,已引用 从: main.o ld 中的 Main(int, char**):找不到体系结构 x86_64 的符号 clang:错误:链接器命令失败,退出代码 1(使用 -v 查看调用) make: *** [simple-project.app/Contents/MacOS/simple-project] 错误 1 00:04:36: 进程“/usr/bin/make”以代码 2 退出。出错时 构建/部署项目 simple-project (kit: Desktop Qt 5.7.0 clang 64bit) 执行步骤“Make”时 00:04:36:经过时间:00:27。
【问题讨论】:
-
我将您的代码粘贴到 main.cpp 中,它在这里工作正常。您的案例实际上涉及更多代码吗?