我正在Qt创建大型项目。我在那里创建了子项目。我的问题是建立目的地。我会像这样简化我的问题:
我必须构建库和二进制文件。我的库有以下Qt项目设置:
dict
我的可执行二进制文件具有以下Qt项目设置:
TARGET = MyLib
CONFIG(debug, debug|release) {
TARGET.path = $$OUT_PWD/MyProject/debug
} else {
TARGET.path = $$OUT_PWD/MyProject/release
}
INSTALLS += TARGET
#DESTDIR += TARGET
TEMPLATE = lib
具有这些设置的编译器VS2017在以下位置创建输出:
TARGET = MyExecutable
CONFIG(debug, debug|release) {
TARGET.path = $$OUT_PWD/MyProject/debug
} else {
TARGET.path = $$OUT_PWD/MyProject/release
}
INSTALLS += TARGET
#DESTDIR += TARGET
TEMPLATE = app
LIBS += -L$$OUT_PWD/MyProject/... -lMyLib (row is different, but it is not important now)
我希望输出如下:
$$OUT_PWD/MyLib/debug/MyLib.dll
$$OUT_PWD/MyLib/release/MyLib.dll
$$OUT_PWD/MyExecutable/debug/MyExecutable.exe
$$OUT_PWD/MyExecutable/release/MyExecutable.exe
我之所以想要输出那样,我想调试从可执行文件跳转的库。 MyExecutable.exe现在无法执行,因为它没有正确路径的MyLib.dll。如果我将两个项目都放在一起:
$$OUT_PWD/MyProject/debug/MyLib.dll
$$OUT_PWD/MyProject/release/MyLib.dll
$$OUT_PWD/MyProject/debug/MyExecutable.exe
$$OUT_PWD/MyProject/release/MyExecutable.exe
名为“TARGET”的文件夹将创建如下:
DESTDIR += TARGET
我正在为Windows做测试解决方案,但将来该项目应该是多平台的。我想我太老了电脑编程......
答案 0 :(得分:1)
谢谢大家,这是我对所有子项目问题的最终(Windows)解决方案:
CONFIG(debug, debug|release) {
DESTDIR += $$OUT_PWD/../MyProject/debug
TARGET.path = $$OUT_PWD/../MyProject/debug
LIBS += -L$$OUT_PWD/../MyProject/debug
} else {
DESTDIR += $$OUT_PWD/../MyProject/release
TARGET.path = $$OUT_PWD/../MyProject/release
LIBS += -L$$OUT_PWD/../MyProject/release
}
INSTALLS += TARGET
#LIBS += -lMyLib
message(The $$TEMPLATE $$TARGET will be installed in $$DESTDIR)