Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In addition to <a href="https://stackoverflow.com/questions/1417776/how-to-use-qmakes-subdirs-template/1417801#1417801">Troubadour's comment</a>, I would note that the <code>SUBDIRS</code> target is only good for specifying subdirectories. Therefore, your extra line of </p> <pre><code>SOURCES += main.cpp </code></pre> <p>in your project.pro file is incorrect, and will likely fail to build your main.cpp file, at worst. At best, qmake will refuse to parse the file, since it has conflicting specifications in it.</p> <p>I've used the <code>SUBDIRS</code> template a few times, and it does well if you can build parts into more-or-less independent libraries, apparently like you have with the logic and the gui separate. Here is one way to do this:</p> <pre><code>project_dir/ -project.pro -common.pri -logic/ ----logic.pro ----some logic files -gui/ ----gui.pro ----gui files -build/ ----build.pro ----main.cpp </code></pre> <p>project.pro:</p> <pre><code>TEMPLATE = subdirs SUBDIRS = logic \ gui # build must be last: CONFIG += ordered SUBDIRS += build </code></pre> <p>common.pri:</p> <pre><code>#Includes common configuration for all subdirectory .pro files. INCLUDEPATH += . .. WARNINGS += -Wall TEMPLATE = lib # The following keeps the generated files at least somewhat separate # from the source files. UI_DIR = uics MOC_DIR = mocs OBJECTS_DIR = objs </code></pre> <p>logic/logic.pro:</p> <pre><code># Check if the config file exists ! include( ../common.pri ) { error( "Couldn't find the common.pri file!" ) } HEADERS += logic.h SOURCES += logic.cpp # By default, TARGET is the same as the directory, so it will make # liblogic.a (in linux). Uncomment to override. # TARGET = target </code></pre> <p>gui/gui.pro:</p> <pre><code>! include( ../common.pri ) { error( "Couldn't find the common.pri file!" ) } FORMS += gui.ui HEADERS += gui.h SOURCES += gui.cpp # By default, TARGET is the same as the directory, so it will make # libgui.a (in linux). Uncomment to override. # TARGET = target </code></pre> <p>build/build.pro:</p> <pre><code>TEMPLATE = app SOURCES += main.cpp LIBS += -L../logic -L../gui -llogic -lgui # Will build the final executable in the main project directory. TARGET = ../project </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload