Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Specify directories for UIC, MOC, and Object Files for each Module in an Application
Forum Update on Monday, May 27th 2025

Specify directories for UIC, MOC, and Object Files for each Module in an Application

Scheduled Pinned Locked Moved Unsolved General and Desktop
16 Posts 2 Posters 4.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isaacEnrique
    wrote on last edited by
    #1

    Greetings.

    I have an application composed of several modules. Each module is in a different namespace, and the source files of each module are grouped into subdirectories with the name of the corresponding namespace.

    For example: a module that implements operations of mathematical morphology is in the namespace "Morph". All class files (.h, .cpp, etc.) of this module are in the "morph" subdirectory within the application's home directory.

    In this way, there are different classes that have the same name, but belong to different namespaces and subdirectories. As there are classes of the same name however, I have problems compiling since the outputs of uic and moc for different classes are written to the same file (there is overwriting). The same happens with object files (.o) corresponding to two classes of the same name.

    I want to know how to specify different subdirectories for the outputs of the uic, moc and object files for each class in my application.

    Currently all the output of the uic, moc and files object of my application go the directories named "uic", "moc" and "obj". In particular, I would like to be able to specify (within each of those three previous directories) subdirectories with the names of the modules in my application.

    In principle, is it possible ?, How to specify that in my project file (.pro)?
    What other options exist to handle this problem?

    Thank you in advance for any help and/or suggestion.

    Isaac Pérez
    Programming is understanding.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Can you show your current .pro file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • I Offline
        I Offline
        isaacEnrique
        wrote on last edited by
        #3

        The file is a bit long. The classes that are called the same are AppDlg and ConfDlg. They belong to the modules "Morph" and "Sgm".

        TARGET   = Cimahis
        TEMPLATE = app
        
        #Config. Compilador
        QMAKE_CXXFLAGS += -std=c++11
        
        #Modulos Qt
        QT += webkit
        
        #Dependencia Externas
        unix {
            INCLUDEPATH += \
                /usr/include/opencv \
                /usr/include/opencv2
        
            LIBS += \
                -lopencv_core \
                -lopencv_imgproc \
                -lopencv_highgui
        }
        
        win32 {
            INCLUDEPATH += \
                3rdparty/tbb/include \
                3rdparty/opencv/include
        
            LIBS += \
                -L$${PWD}/3rdparty/tbb/bin/win -ltbb \
                -L$${PWD}/3rdparty/opencv/bin/win -lopencv_core249d \
                                                  -lopencv_imgproc249d \
                                                  -lopencv_highgui249d
        
            #conf. ambiente de ejecucion
            env_config_target.target    =   sys_path_config
            env_config_target.commands  =   set PATH=$(PATH);$${PWD}/3rdparty/tbb/bin/win;$${PWD}/3rdparty/opencv/bin/win
        
            QMAKE_EXTRA_TARGETS +=  env_config_target
            PRE_TARGETDEPS      +=  sys_path_config
        }
        
        #Input
        INCLUDEPATH += \
            headers \
            headers/color \
            headers/ctrs \
            headers/morph \
            headers/morph/morphometry \
            headers/texture \
            headers/sgm
        
        DEPENDPATH += \
            sources \
            sources/color \
            sources/ctrs \
            sources/morph \
            sources/morph/morphometry \
            sources/texture \
            sources/sgm
        
        FORMS += \
            forms/ComboBox.ui \
            forms/Reporte.ui \
            forms/Ayuda.ui \
            forms/visualizarhistograma.ui \
            forms/ventanaumbral.ui \
            forms/elegirFiltros.ui \
            forms/ventanaparametrosfiltro.ui \
            forms/configurarwavelets.ui \
            forms/interfazforma.ui \
            forms/graficoparametros.ui \
            forms/ventanaconfigparametros.ui \
            forms/morph/AppDlg.ui \
            forms/morph/ConfDlg.ui \
            forms/sgm/AppDlg.ui \
            forms/sgm/ConfDlg.ui
        
        HEADERS += \
            headers/Misc.h \
            headers/Imagen.h \
            headers/interfazSistema.h \
            headers/ComboBox.h \
            headers/Reporte.h \
            headers/Ayuda.h \
            headers/AreaImagen.h \
            headers/qcustomplot.h \
            headers/Cimahis.h \
            headers/color/Color.h \
            headers/color/fabricaObjetos.h \
            headers/color/Histograma.h \
            headers/color/visualizarhistograma.h \
            headers/color/lienzoHistograma.h \
            headers/color/ventanaumbral.h \
            headers/color/elegirFiltros.h \
            headers/color/ventanaparametrosfiltro.h \
            headers/color/filtros.h \
            headers/color/threadFiltro.h \
            headers/color/segmentacion.h \
            headers/ctrs/costos.h \
            headers/ctrs/interfazforma.h \
            headers/ctrs/livewire.h \
            headers/ctrs/qgraphicsviewpersonalizado.h \
            headers/morph/Morph.h \
            headers/morph/AppDlg.h \
            headers/morph/ConfDlg.h \
            headers/morph/morphometry/graficoparametros.h \
            headers/morph/morphometry/morfometria.h \
            headers/morph/morphometry/punto.h \
            headers/morph/morphometry/ventanaconfigparametros.h \
            headers/texture/Wavelet.h \
            headers/texture/ConfigurarWavelets.h \
            headers/sgm/Sgm.h \
            headers/sgm/GfxIt.h \
            headers/sgm/GfxMkr.h \
            headers/sgm/GfxBox.h \
            headers/sgm/GfxCtr.h \
            headers/sgm/ImVw.h \
            headers/sgm/AppDlg.h \
            headers/sgm/ConfDlg.h
        
        SOURCES += \
            sources/Misc.cpp \
            sources/Imagen.cpp \
            sources/interfazSistema.cpp \
            sources/ComboBox.cpp \
            sources/Reporte.cpp \
            sources/Ayuda.cpp \
            sources/AreaImagen.cpp \
            sources/qcustomplot.cpp \
            sources/Cimahis.cpp \
            sources/color/Color.cpp \
            sources/color/fabricaObjetos.cpp \
            sources/color/Histograma.cpp \
            sources/color/visualizarhistograma.cpp \
            sources/color/lienzoHistograma.cpp \
            sources/color/ventanaumbral.cpp \
            sources/color/elegirFiltros.cpp \
            sources/color/ventanaparametrosfiltro.cpp \
            sources/color/filtros.cpp \
            sources/color/threadFiltro.cpp \
            sources/color/segmentacion.cpp \
            sources/ctrs/costos.cpp \
            sources/ctrs/interfazforma.cpp \
            sources/ctrs/livewire.cpp \
            sources/ctrs/qgraphicsviewpersonalizado.cpp \
            sources/morph/Morph.cpp \
            sources/morph/AppDlg.cpp \
            sources/morph/ConfDlg.cpp \
            sources/morph/morphometry/graficoparametros.cpp \
            sources/morph/morphometry/morfometria.cpp \
            sources/morph/morphometry/punto.cpp \
            sources/morph/morphometry/ventanaconfigparametros.cpp \
            sources/texture/Wavelet.cpp \
            sources/texture/ConfigurarWavelets.cpp \
            sources/sgm/Sgm.cpp \
            sources/sgm/GfxIt.cpp \
            sources/sgm/GfxMkr.cpp \
            sources/sgm/GfxBox.cpp \
            sources/sgm/GfxCtr.cpp \
            sources/sgm/ImVw.cpp \
            sources/sgm/AppDlg.cpp \
            sources/sgm/ConfDlg.cpp \
            sources/main.cpp
        
        RESOURCES += \
            resources/resources.qrc
        
        #Output
        UI_DIR      = uic
        MOC_DIR     = moc
        OBJECTS_DIR = obj
        
        #Instalacion
        CONFIG(  debug, debug|release): DESTDIR = $${OUT_PWD}/debug
        CONFIG(release, debug|release): DESTDIR = $${OUT_PWD}/release
        unix:   OS_TAG = unix
        win32:  OS_TAG = win
        
        tbblib.path  = $$DESTDIR
        tbblib.files = 3rdparty/tbb/bin/$${OS_TAG}/*
        
        opencvlib.path  = $$DESTDIR
        opencvlib.files = 3rdparty/opencv/bin/$${OS_TAG}/*
        
        INSTALLS += tbblib opencvlib
        

        Isaac Pérez
        Programming is understanding.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then use CONFIG += object_parallel_to_source

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • I Offline
            I Offline
            isaacEnrique
            wrote on last edited by
            #5

            Okay, but

            Can you give me some explanation (or some link to study) about it?

            Isaac Pérez
            Programming is understanding.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Sure: http://code.qt.io/cgit/qt/qtbase.git/commit/?id=47df12225918ba82abe35921af19e547717da58b

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • I Offline
                I Offline
                isaacEnrique
                wrote on last edited by
                #7

                I continue to have problems compiling. Warnings of type:

                Ignoring old recipe for target 'moc/moc_AppDlg.cpp'
                Overriding recipe for target 'moc/moc_AppDlg.cpp'

                In addition to several related errors: The member functions of Morph::AppDlg are not defined.

                Isaac Pérez
                Programming is understanding.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Did you re-run qmake or do a clean re-build (i.e. nuke the shadow-build folder) after adding the CONFIG option ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • I Offline
                    I Offline
                    isaacEnrique
                    wrote on last edited by
                    #9

                    Yes. I deleted the shadow-build folder, and rebuilt the application. I continue to get errors/warnings mentioned above.

                    I'm working with Qt 4.8.6 and Qt Creator 2.5.2 (I do not know if that influences).

                    Isaac Pérez
                    Programming is understanding.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Oh yes, that influences greatly since object_parallel_to_source is Qt 5 feature.

                      Are you locked to that old version of Qt ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • I Offline
                        I Offline
                        isaacEnrique
                        wrote on last edited by
                        #11

                        Yes, at least temporarily I am required to work with Qt 4.8.6.

                        Is there any option to get that same functionality in the Qt version I'm working with?

                        Isaac Pérez
                        Programming is understanding.

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          If you are building Qt yourself, you could try to back port the patch.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • I Offline
                            I Offline
                            isaacEnrique
                            wrote on last edited by
                            #13

                            I'm not building Qt by myself.

                            I wonder if there is any way (set of instructions specified in the .pro file, maybe something like what I used under the comment #Instalacion), in Qt 4.8.6, to achieve something similar to the functionality of the object_parallel_to_source option; or something that allows me to have two classes of the same name in my project.

                            Can you do such a thing?

                            Isaac Pérez
                            Programming is understanding.

                            1 Reply Last reply
                            0
                            • SGaistS Offline
                              SGaistS Offline
                              SGaist
                              Lifetime Qt Champion
                              wrote on last edited by
                              #14

                              You can use object_with_source BUT (and it's a big one) you lose the ability to do out of source builds.

                              On a side note, Qt 4.8.6 is not the latest of the Qt 4 series, there's Qt 4.8.7.

                              Interested in AI ? www.idiap.ch
                              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                              1 Reply Last reply
                              0
                              • I Offline
                                I Offline
                                isaacEnrique
                                wrote on last edited by
                                #15

                                I will try to use object_with_source.

                                On the other hand, I wonder if it will be possible to manually emulate (with instructions in the .pro file, with some script, or something like that) the functionality of the object_parallel_to_source option.

                                Isaac Pérez
                                Programming is understanding.

                                1 Reply Last reply
                                0
                                • SGaistS Offline
                                  SGaistS Offline
                                  SGaist
                                  Lifetime Qt Champion
                                  wrote on last edited by
                                  #16

                                  I'd say highly unlikely. Note that you could also try with cmake rather than qmake.

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  1 Reply Last reply
                                  0

                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • Users
                                  • Groups
                                  • Search
                                  • Get Qt Extensions
                                  • Unsolved