TEMPLATE = subdirsCONFIG += orderedSUBDIRS = lib gui console testgui.depends = libconsole.depends = libtest.depends = lib
--- testlib.proTEMPLATE = subdirsSUBDIRS = lib testtest.depends = lib--- lib/lib.proQT -= core guiTARGET = libTEMPLATE = libDESTDIR = $$PWD/../binSOURCES += lib.cppCONFIG += staticlibHEADERS += lib.h--- lib/lib.cpp#include "lib.h"std::string TestLib::getText() { return "zzzzz"; }--- lib/lib.h#ifndef LIB_H#define LIB_H#include <iostream>class TestLib {public: static std::string getText(); };#endif // LIB_H--- test/test.proQT -= core guiCONFIG += c++11TARGET = testCONFIG += consoleCONFIG -= app_bundleTEMPLATE = appSOURCES += main.cppINCLUDEPATH += $$PWD/../libLIBS += -L$$PWD/../bin -llib--- test/main.cpp#include "../lib/lib.h"int main(){ std::cout << TestLib::getText(); return 0; }
PRE_TARGETDEPS = $$PWD/../bin/liblib.a