Quantcast
Channel: Qt DevNet forums: Installation and Deployment
Viewing all articles
Browse latest Browse all 2113

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

$
0
0
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 [github.com] following the blog from Svenn-Arne Dragly [dragly.org] 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

Viewing all articles
Browse latest Browse all 2113

Trending Articles