Troubadour's comment 외에도 SUBDIRS
대상은 하위 디렉터리 지정에 유용합니다. 따라서 project.pro 파일에
SOURCES += main.cpp
의 추가 줄이 잘못되어 최악의 경우 main.cpp 파일을 빌드하지 못할 수도 있습니다. 기껏해야, qmake는 파일에 구문이 충돌하기 때문에 파일을 구문 분석하지 않습니다.
나는 SUBDIRS
템플릿을 몇 번 사용해 본 적이 있습니다. 로직과 gui를 가지고있는 것처럼 자주 또는 더 적은 독립 라이브러리에 부품을 만들 수 있다면 잘됩니다.
project_dir/
-project.pro
-common.pri
-logic/
----logic.pro
----some logic files
-gui/
----gui.pro
----gui files
-build/
----build.pro
----main.cpp
project.pro :
TEMPLATE = subdirs
SUBDIRS = logic \
gui
# build must be last:
CONFIG += ordered
SUBDIRS += build
일반적인 여기에이 작업을 수행하는 하나의 방법입니다.PRI :
#Includes common configuration for all subdirectory .pro files.
INCLUDEPATH += . ..
WARNINGS += -Wall
TEMPLATE = lib
# The following keeps the generated files at least somewhat separate
# from the source files.
UI_DIR = uics
MOC_DIR = mocs
OBJECTS_DIR = objs
논리/logic.pro :
# Check if the config file exists
! include(../common.pri) {
error("Couldn't find the common.pri file!")
}
HEADERS += logic.h
SOURCES += logic.cpp
# By default, TARGET is the same as the directory, so it will make
# liblogic.a (in linux). Uncomment to override.
# TARGET = target
GUI/gui.pro :
! include(../common.pri) {
error("Couldn't find the common.pri file!")
}
FORMS += gui.ui
HEADERS += gui.h
SOURCES += gui.cpp
# By default, TARGET is the same as the directory, so it will make
# libgui.a (in linux). Uncomment to override.
# TARGET = target
빌드/build.pro :
TEMPLATE = app
SOURCES += main.cpp
LIBS += -L../logic -L../gui -llogic -lgui
# Will build the final executable in the main project directory.
TARGET = ../project
project.pro의 SOURCES 지시문에 대한 좋은 지적. 나는 그것을 완전히 놓쳤다. – Troubadour
이 포괄적 인 답변 주셔서 감사합니다. 제 학습을 시작하는 것이 좋은 포인트입니다. – zarzych
"주문한"것은 세계적인 느낌입니다. 처음 두 라이브러리를 동시에 만드는 것은 아닙니다. –