为了简化这种情况,我们假设有2个文件:core.cpp和main.cpp.
core.cpp包含程序的功能并main.cpp包含基本main()实现.
我想要Qt(使用qmake和.pro文件)
core.a,然后main.cpp建立main.exe.如何在qmake文件中进行设置?
Mas*_*sci 32
文件系统布局:
MyProject
|_ myproject.pro
|_ core
|_ core.cpp
|_ core.h
|_ core.pro
|_ app
|_ main.cpp
|_ app.pro
Run Code Online (Sandbox Code Playgroud)
myproject.pro:
TEMPLATE = subdirs
CONFIG += ordered
SUBDIRS = core \
app
app.depends = core
Run Code Online (Sandbox Code Playgroud)
core.pro:
TEMPLATE = lib
CONFIG += staticlib
HEADERS = core.h
SOURCES = core.cpp
Run Code Online (Sandbox Code Playgroud)
app.pro:
TEMPLATE = app
SOURCES = main.cpp
LIBS += -L../core -lcore
TARGET = ../app-exe # move executable one dire up
Run Code Online (Sandbox Code Playgroud)