Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt compiler warning: overriding commands for target / ignoring old commands for target

Tags:

c++

qt

qmake

moc

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?

like image 875
sashoalm Avatar asked Jan 18 '11 09:01

sashoalm


2 Answers

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 :

SOURCES += main.cpp\     mainwindow.cpp\     serialHelper.cpp \ serialHelper.cpp  HEADERS  += mainwindow.h\      += serialHelper.h \ serialHelper.h \ typeDefinitions.h 

cpp and header file was repeating itself. I delete the repeating includes and problem solved for me .

like image 144
Kadir Erdem Demir Avatar answered Sep 17 '22 08:09

Kadir Erdem Demir


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

SOURCES += foo.cpp SOURCES += bar.cpp SOURCES += bla/foo.cpp SOURCES += bla/bar.cpp 

In this case QMake would complain about both foo.o and bar.o.

The solution to this problem is to add

CONFIG += object_parallel_to_source 

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.

like image 41
rsp1984 Avatar answered Sep 21 '22 08:09

rsp1984