Project structure help/suggestions.

  • I am creating a project that I want to structure a little bit differently from the usual default way, mainly out of interest, thus what I will show below might be wrong or not a good idea. In any case this is what I have until now

    The contents of these files are as follows:

    TEMPLATE = subdirs
    SUBDIRS = Logger Engine App
    DISTFILES += doc/* mainpage.dox Doxyfile
    OTHER_FILES += \
        TODO \
        Copyright \
    # build should be last.
    CONFIG += ordered
    SUBDIRS += build
    PACKAGE_VERSION = $$ProjectVersion
    PACKAGE_NAME= Project
,, (Empty for now)

    TEMPLATE = lib
    UI_DIR = uics
    MOC_DIR = mocs
    OBJECTS_DIR = objs
    QT +=
    CONFIG(debug, debug|release) {
    HEADERS +=
    SOURCES +=


    exists(user.conf): include(user.conf)
    isEmpty(ProjectVersion) {
        ProjectVersion = 1.1
        cache(ProjectVersion, set, ProjectVersion)
    WARNINGS += -Wall

    TEMPLATE = app
    SOURCES += main.cpp 
    #LIBS += -L../Logger -L../Engine -L../App -llogger -lengine -lapp
    TARGET = ../

    The idea is that build/ will take care of packaging everything into a final application. All other components, like the logger, will be libraries loaded in the app.

    App/ will contain the applications ui, written in qml, and Engine/ all the code that will provide functionality to the ui.

    Can someone identify any issues with the approach on general. Suggestions or ideas on improving my structure are always welcomed. Maybe you have your own way of structuring your apps and would care to share it.

    TEMPLATE = lib is only generating a .dll file and not a .a file. I am not sure if this is correct or not though. Should I link to that dll directly with something like this:

    CONFIG( debug, debug|release ) {
        LIBS += "../dist/debug/Loggerd.dll"
        LIBS += "../dist/debug/Engined.dll"
        DESTDIR += "../dist/debug"
    } else {
        LIBS += "../dist/release/Logger.dll"
        LIBS += "../dist/release/Engine.dll"
        DESTDIR += "../dist/release"

    or use

    CONFIG	-= dll
    CONFIG	+= shared static

    and link to the resulting .lib?


  • Lifetime Qt Champion


    You don't link to .dll files. If you don't have .lib files generated that means that you didn't do the proper export/import stuff. It's described here

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.