How do I build a static library and executable with Qt?

Filesystem layout:

MyProject
|_ myproject.pro
|_ core
   |_ core.cpp
   |_ core.h
   |_ core.pro
|_ app
   |_ main.cpp
   |_ app.pro

myproject.pro:

TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = core \
          app
app.depends = core

core.pro:

TEMPLATE = lib
CONFIG += staticlib
HEADERS = core.h
SOURCES = core.cpp

app.pro:

TEMPLATE = app
SOURCES = main.cpp
LIBS += -L../core -lcore
TARGET = ../app-exe # move executable one dire up

Leave a Comment

tech