QtCreator构建返回collect2:ld返回退出状态1

Aus*_*yde 8 c++ ld qt-creator

在QtCreator中构建多个不同的项目时,我遇到了以下构建错误:

collect2: ld returned 1 exit status
Run Code Online (Sandbox Code Playgroud)

在仅更改了一些内容(不应该更改构建中的任何重要内容)之后,如果它已经出现,它将会消失,或者如果它不存在则会出现.

在我目前的学校项目计划中,我正在尝试编译rock03.cpp.它是构建中唯一的文件,并且具有main()方法.我刚刚成功运行它,并回去改变某些if()s 的顺序,现在,我只得到两个相关的警告:

overriding commands for target 'rock03.o'
Run Code Online (Sandbox Code Playgroud)

和

ignoring old commands for target 'rock03.o'
Run Code Online (Sandbox Code Playgroud)

以及有问题的错误.

有谁知道为什么会这样?我似乎无法以任何合理的确定性重现错误,并且QtCreator在构建之前并没有抱怨任何事情.

谢谢

Pat*_*ola 5

如果唯一的消息错误是关于链接器的错误,原因可能是您的程序仍在运行且链接器无法访问二进制文件.确保您的应用程序已停止或在仍在运行时将其终止.Qtcreator在编译之前从不检查先前的运行是否已停止.


Geo*_*Shg 5

这发生在我身上,因为我做的头文件中的声明,然后删除该功能在cpp文件,我忘了删除decleration在头中.例如...

 //header file
class CLASS : public Q_OBJECT
{
...
protected:
void mouseMoveEvent(QMouseEvent*);
}

//source file

void CLASS::mouseMoveEvent(QMouseEvent*e)
{
...
}
    //I'll delete this, then forget to delete "void mouseMoveEvent(QMouseEvent*);" in the header file
Run Code Online (Sandbox Code Playgroud)


Aus*_*yde -1

检查“编译输出”窗格显示 .pro 文件试图链接同一个 .cpp 文件两次。