To simplify the situation, lets say that there are 2 files: core.cpp and main.cpp.
core.cpp contains the functionality of the program and main.cpp contains the basic main() implementation.
I want Qt (using qmake and the .pro files) to
core.a and then main.cpp to build main.exe. How do I set this up in the qmake file?
Qt is a framework, not a library. This isn't a hard-and-fast distinction enforced by the programming language, rather, it describes how the code is designed and intended to be used: A library is someone else's code that is used by your code.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With