Important: Please read the Qt Code of Conduct -

App does not build

  • Hello

    I have similar problem and still looking for a solution

    In the project there are many files with same name and in different directories


    there was the problem with object files put in plain directory which was successfully solved with

    CONFIG += object_parallel_to_source # recreate source folder tree for object files (replaces object_with_source). We need this because we have many same name files.

    but there is still one more problem that moc files are generated wrong way and I am getting errors

    Makefile:4830: warning: overriding recipe for target 'moc_controller.cpp'
    Makefile:4358: warning: ignoring old recipe for target 'moc_controller.cpp'


    /home/.../controllers/controller.cpp:3: error: undefined reference to `vtable for Acquiring::Controller'

    where Controller is derived from QObject

    I know one of the solutions is to separate the project to several projects or rename files, but is there an option to make qmake generate moc files correctly?

  • Lifetime Qt Champion

    Besides of using pri files (sub projects ) for the duplicate names
    and use MOC_DIR for each i dont know any good way to solve it.

    Its not an option to simply rename the files ?

  • @mrjj MOC_DIR does not affect each .pri file, but whole project instead (

  • Lifetime Qt Champion

    so even you have one MOC_DIR for top level project and a MOC_DIR inside each .pri file
    the names still collide ?

  • @mrjj yes, probably MOC_DIR works once per .pro file
    I still can not find solution. Instead of many controller.moc files the only one is generated and it stays in one folder.

  • Lifetime Qt Champion

    and each controller is included via its PRI file ?
    so the main project is the unique files and includes all controllers as PRI files only ?
    I have not personally tried this but it was my understanding it could work.
    But i guess not then.

Log in to reply