54

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?

1
  • Just do a clean build and these will be gone.
    – ismail
    Jan 18, 2011 at 9:29

4 Answers 4

119

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 .

3
  • 8
    you saved me from a lot of frustration
    – nkint
    Jul 24, 2013 at 17:09
  • 4
    Me too this also happened on SUBDIRS.
    – reggie
    Jul 31, 2014 at 6:57
  • 4
    Note that the repeat may be caused when two files have the same name and are each mentioned in different included .pri files.
    – Troyseph
    Sep 2, 2016 at 15:14
17

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.

0
9

make clean and then make 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.

2
  • 4
    If this does not solve the problem, then it is likely you have the mainwindow.h file listed more than once in your HEADERS variable in the .pro file. Jan 20, 2011 at 22:33
  • Thanks, it turned out I really did have it listed twice. How do I mark your answer as the correct one? Or should I just mark the parent?
    – sashoalm
    Feb 12, 2011 at 6:57
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.