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. Project structure help/suggestions.
Qt 6.11 is out! See what's new in the release blog

Project structure help/suggestions.

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 810 Views 2 Watching
  • 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.
  • ealioneE Offline
    ealioneE Offline
    ealione
    wrote on last edited by ealione
    #1

    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

    • Poject/
      • project.pro
      • App/
        • app.pro
      • Engine/
        • engine.pro
      • Logger/
        • logger.pro
      • root.pri

    The contents of these files are as follows:

    project.pro

    include(root.pri)
    
    TEMPLATE = subdirs
    
    SUBDIRS = Logger Engine App
    
    DISTFILES += doc/* mainpage.dox Doxyfile
    OTHER_FILES += README.md \
        TODO \
        Copyright \
        Changelog
    
    # build should be last.
    CONFIG += ordered
    SUBDIRS += build
    
    PACKAGE_VERSION = $$ProjectVersion
    PACKAGE_NAME= Project
    

    App.pro, Engine.pro, Logger.pro (Empty for now)

    INCLUDEPATH += $$PWD
    DEPENDPATH += $$PWD
    
    TEMPLATE = lib
    
    UI_DIR = uics
    MOC_DIR = mocs
    OBJECTS_DIR = objs
    
    QT +=
    
    CONFIG(debug, debug|release) {
        DEFINES += SUPERVERBOSE
    }
    
    HEADERS +=
    
    SOURCES +=
    

    root.pri

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

    build.pro

    INCLUDEPATH += $$PWD
    DEPENDPATH += $$PWD
    
    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.

    EDIT:
    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?

    Thanks.

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

      Hi,

      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

      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