2017-01-02 212 views
-1

我想在QT Creator中运行这个简单的代码。QT创建者:错误:找不到架构x86_64的符号

#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; 
    } 

但我一直在解决这两个问题。

  1. 错误:符号(S)没有发现建筑x86_64的

  2. 错误:连接命令,退出代码为1(使用-v看看调用)

并全面失败我得到的描述是这样的。内部编译输出。

Undefined symbols for architecture x86_64: "Main()", referenced from: Main(int, char**) in main.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make: *** [simple-project.app/Contents/MacOS/simple-project] Error 1 00:04:36: The process "/usr/bin/make" exited with code 2. Error while building/deploying project simple-project (kit: Desktop Qt 5.7.0 clang 64bit) When executing step "Make" 00:04:36: Elapsed time: 00:27.

+0

我把你的代码粘贴到main.cpp中,它在这里工作的很好。实际上你的案例涉及更多的代码? – E4z9

回答

0

你的代码没有问题,如果你复制/粘贴到一个新的项目,它编译就好了。问题是某些.obj文件或Makefile文件在其中存在问题。这些文件基本上包含尚未链接的编译代码。这些文件并不总是在每个编译时更新,只有当生成它们的源代码发生更改时才会更新。这意味着当项目设置发生变化时(您显然会这样做),这些文件不一定会更改以适应新设置,因此会生成错误。这个系统是为了加快编译速度,但有时可能会造成滋扰,就像你的情况一样。要解决您的问题,只需删除包含这些文件和编译后的.exe文件的文件夹。使用Qt Creator这个文件夹通常有一个类似于build-untitled-Desktop_Qt_5_7_0_MSVC2015_32bit-Release的名称。删除文件夹时,所有文件都将被删除,因此编译器将不得不使用这次正确的设置生成新文件。

相关问题