C++ Qt Multiple Definitions

Answer just for reference:

I was including

#include myclass.cpp

instead of

#include myclass.h

This can also happen if you have two .ui files with the same name in different folders. Their corresponding headers are built in the same directory, resulting in one being overwritten. At least that was my problem.


I've seen this happen before when a source file got duplicated in the project (.pro or .pri) file. Check all of the "SOURCES =" and "SOURCES +=" lines in your project file and make sure the cpp file is not in there more than once.


I don't use MinGW but this sounds like a linker error rather than a compiler error. If this is the case then you should check that the .CPP file is not added to the project twice. I also noticed that the extension is "php", this is very unusual as it should be "cpp".