Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Qt Project with multiple subdirs, apps, libs and tests, how to set-up?
QtWS25 Last Chance

Qt Project with multiple subdirs, apps, libs and tests, how to set-up?

Scheduled Pinned Locked Moved Installation and Deployment
7 Posts 3 Posters 4.4k 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.
  • T Offline
    T Offline
    TOAOMatis
    wrote on 5 Jan 2015, 07:38 last edited by
    #1

    Dear all,

    Let me start by wishing you a healthy, prosperous and /ˈkjuːt/ 2015!

    I'm not sure whether this topic is more "Tools" or "Installation and Deployment" related, please feel free to move it do the other (appropriate) folder if needed!

    Currently I've started a new Qt Project within Qt Creator (3.3.0 opensource) which will contain several stand-alone apps and shared libs between those apps. All apps and libraries will have their own tests and there will be an overall test-suite.

    Currently I've made the following project structure / setup:
    @./myProject.pro [subdir]

    ./apps/myApp1/myApp1.pro [subdir]
    ./apps/myApp1/myApp1/myApp1.pro [app]
    ./apps/myApp1/myApp1Tests/myApp1Tests.pro [console]

    ./apps/myApp2/myApp2.pro [subdir]
    ./apps/myApp2/myApp2/myApp2.pro [app]
    ./apps/myApp2/myApp2Tests/myApp2Tests.pro [console]

    ./libs/myLib1/myLib1.pro [subdir]
    ./libs/myLib1/myLib1/myLib1.pro [lib]
    ./libs/myLib1/myLib1Tests/myLib1Tests.pro [console]

    ./libs/myLib2/myLib2.pro [subdir]
    ./libs/myLib2/myLib2/myLib2.pro [lib]
    ./libs/myLib2/myLib2Tests/myLib2Tests.pro [console]

    ./myProjectTests/myProjectTests.pro [console]@

    This structure is heavily based on the following suggestion "Hello-QT":https://github.com/jtpedersen/Hello-QT following the blog from "Svenn-Arne Dragly":http://dragly.org/2014/03/13/new-project-structure-for-projects-in-qt-creator-with-unit-tests/

    In my apps I would like to use the following include path:

    @#include <myLib1/MyLib1.h>@

    instead of

    @#include <../../../libs/myLib1/myLib1/MyLib1.h>@

    Without having to (re)add all the library include paths in every app when I add a new library or app.

    The guidelines say that this can be achieved to add a defaults.pri file, which contains all the library include folders.

    @INCLUDEPATH += $$PWD/libs/myLib1
    INCLUDEPATH += $$PWD/libs/myLib2

    SRC_DIR = $$PWD@

    Now the linker tells me the following:

    @/home/mathijs/git/qt/build-myProject-Desktop_Qt_5_4_0_GCC_64bit-Debug/apps/myApp1/myApp1/../../../../myProject/apps/myApp1/myApp1/main.cpp:11: undefined reference to MyLib1::MyLib1() /home/mathijs/git/qt/build-myProject-Desktop_Qt_5_4_0_GCC_64bit-Debug/apps/myApp1/myApp1/../../../../myProject/apps/myApp1/myApp1/main.cpp:12: undefined reference to MyLib2::MyLib2()@

    So I've updated the defaults.pri file and added the LIBS:

    @INCLUDEPATH += $$PWD/libs/myLib1
    INCLUDEPATH += $$PWD/libs/myLib2

    LIBS += -lmyLib1 -lmyLib2

    SRC_DIR = $$PWD@

    Still no succes

    @/usr/bin/ld: cannot find -lmyLib1
    /usr/bin/ld: cannot find -lmyLib2@

    So I explicitly set the dependencies in the myProject.pro file

    @TEMPLATE = subdirs

    SUBDIRS +=
    myApp1
    myApp2
    myLib1
    myLib2
    myProjectTests

    Apps

    myApp1.subdir = apps/myApp1
    myApp2.subdir = apps/myApp2

    Libs

    myLib1.subdir = libs/myLib1
    myLib2.subdir = libs/myLib2

    Dependancies

    myApp1.depends = myLib1 myLib2

    OTHER_FILES +=
    defaults.pri@

    Unfortunate, this doesn't do the trick, although the libmyLib1.so and libmyLib2.so files are created in the shadow build directory.

    What did I do wrong?

    Many thanks in advance!

    TOAOMatis

    1 Reply Last reply
    0
    • A Offline
      A Offline
      at1970
      wrote on 5 Jan 2015, 08:20 last edited by
      #2

      have you looked in side of CMake tool?
      set of CMakeLists.txt scripts can describe project with any hierarchy

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TOAOMatis
        wrote on 5 Jan 2015, 08:27 last edited by
        #3

        I'm sorry. I'm using just Makefile (g++) under Ubuntu 12.04, so no CMake for me.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          at1970
          wrote on 5 Jan 2015, 08:31 last edited by
          #4

          then maybe http://qt-project.org/forums/viewthread/13250 can help you

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 5 Jan 2015, 22:31 last edited by
            #5

            Hi,

            You need to build your libraries first so use an ordered subdir project with the projects set in the correct order

            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
            • T Offline
              T Offline
              TOAOMatis
              wrote on 6 Jan 2015, 08:01 last edited by
              #6

              [quote author="SGaist" date="1420497065"]Hi,

              You need to build your libraries first so use an ordered subdir project with the projects set in the correct order[/quote]

              I thought I did so with the toplevel project file
              @# Dependancies
              myApp1.depends = myLib1 myLib2@

              I didn't use CONFIG += ordered because of: http://blog.rburchell.com/2013/10/every-time-you-configordered-kitten-dies.html

              I can see that the libraries are build first. But the linker can't find the output directories, when it tries to link the app against the two libraries.

              As a matter of fact, I'm looking for a way to get the build directory for the libraries within my defaults.pri
              $$OUT_PWD doesn't do the trick, while it points to the build directory of the app and not the toplevel build directory.

              1 Reply Last reply
              0
              • A Offline
                A Offline
                at1970
                wrote on 9 Jan 2015, 11:22 last edited by
                #7

                I use config.pri file with simple content
                @# save root directory
                APP_ROOT_DIR = $$PWD@

                and include it in all sub-projects as
                @# configuration
                include(../config.pri)@

                to have start point APP_ROOT_DIR for folders hierarchy.

                1 Reply Last reply
                0

                7/7

                9 Jan 2015, 11:22

                • Login

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