Qt 编译器警告:覆盖目标命令/忽略目标旧命令
当我为 Windows 编译 Qt 项目时,我收到这 2 个警告:
Makefile.Debug:109: warning: overriding commands for target `debug/moc_mainwindow.cpp'
Makefile.Debug:106: warning: ignoring old commands for target `debug/moc_mainwindow.cpp'
我认为它们表明我的项目配置存在问题,问题是什么以及如何修复它?
When I'm compiling my Qt project for Windows I receive these 2 warnings:
Makefile.Debug:109: warning: overriding commands for target `debug/moc_mainwindow.cpp'
Makefile.Debug:106: warning: ignoring old commands for target `debug/moc_mainwindow.cpp'
I assume they indicate some problem with my project config, what is the problem and how do I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我曾经遇到过同样的错误,也许你的问题根源不同,但无论如何我都会写。
在我的 *.pro 文件中,它就像:
cpp 和头文件重复自身。我删除了重复的包含并为我解决了问题。
I got the same error once , maybe source of your problem is different but I will write anyways.
In my *.pro file, it was like :
cpp and header file was repeating itself. I delete the repeating includes and problem solved for me .
在很多情况下,此错误与 QMake 只是将所有目标文件放入构建目录中的平面文件夹中有关,如果两个源文件具有相同的名称,即使它们可能位于不同的文件夹中,也会导致问题。例如
在这种情况下,QMake 会抱怨 foo.o 和 bar.o。
此问题的解决方案是添加
到 .pro 文件,这将使构建文件夹镜像源树的文件夹层次结构。不知道为什么这不是默认值。
问题和解决方案之前已在此处指出,但未在此线程中讨论的警告消息的上下文中指出。
In a lot of cases this error is related to QMake just putting all the object files in a flat folder in the build directory, which then causes problems if two source files have the same name, even though they might be in different folders. Such as
In this case QMake would complain about both foo.o and bar.o.
The solution to this problem is to add
to the .pro file which will cause the build folder to mirror the folder hierarchy of the source tree. Not sure why this isn't the default.
The problem and solution have been previously pointed out here but not in the context of the warning message discussed in this thread.
make clean
然后make
应该可以解决这个问题。 :) (或者右键单击 Qt Creator 中的项目 -> Clean,然后右键单击 Qt Creator 中的项目 -> Rebuild)。如果不起作用,请手动删除makefile并重建然后项目。
make clean
and thenmake
should solve this problem. :) (Or right click on project in Qt Creator -> Clean and then right click on project in Qt Creator -> Rebuild).If it does not work, manually delete the makefile and the rebuild then project.
我也遇到了同样的问题——Makefile 两次包含相同的 .cpp 和 .h 文件,并且给了我的多重定义。首先在这里定义错误。
事实证明,除了 *.pro 文件之外,相关的 .cpp 和 .h 文件也已添加为 qwtfunctions。因此,如果上述答案都不适合您,请检查 qwtfunctions。
I've had the same issue as well -- Makefile included the same .cpp and .h file twice, and was giving me
Multiple definition of <class/function> first defined here
errors.Turns out the .cpp and .h files in question were already added as qwtfunctions, in addition to being in *.pro file. So check qwtfunctions as well if none of the above answers worked for you.