使用 QtCreator 和 QMake 组织项目

发布于 2024-11-29 17:04:55 字数 501 浏览 0 评论 0原文

我正在尝试在 Qt Creator 中创建一个项目,其中表示层和业务逻辑层分为子项目。我举个例子:

MainProject.pro
|
---- BusinessLogic.pro
|       |
|       ---- source/header files
|
---- PresentationLayer.pro
        |
        ---- source/header files

目前,我在表示层的代码通过在.pro文件中指定INCLUDEPATH = ../BusinessLogic/headers来引用业务逻辑项目中的头文件。它似乎有效,但是有更好的方法吗?也许甚至是推荐的方式?

我正在尝试对 lib 文件执行类似的操作,但由于这些文件是在编译时生成的,并且它们可以位于发布或调试文件夹中,所以我不确定如何执行此操作。

这似乎是一种非常常见的组织项目的方式,但我似乎没有找到太多关于如何使用 QtCreator 或 QMake 来完成此任务的信息。

I'm trying to create a project in Qt creator where the presentation layer and and business logic layer are separated into sub projects. Here's an illustration I'm talking about:

MainProject.pro
|
---- BusinessLogic.pro
|       |
|       ---- source/header files
|
---- PresentationLayer.pro
        |
        ---- source/header files

Currently, my code in the presentation layer refers to the header files in the business logic project by specifying INCLUDEPATH = ../BusinessLogic/headers in the .pro file. It appears to work, but is there a better way of doing this? Perhaps even a recommended way?

I'm trying to do something similar with the lib files, but as these are generated at compile time and they can be in either a release or debug folder, I'm not sure how I'd go about doing this.

This seems like a very common way of organizing projects but I don't seem to find much information on how to accomplish this with QtCreator or QMake.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故乡的云 2024-12-06 17:04:55

考虑到包含不同的调试/发布库,您可以在项目文件中执行以下操作:

build_pass:CONFIG(debug, debug|release) {
    LIBS += -L../BusinessLogic/bin/debug -lBusinessLogicd
}
else:build_pass {
    LIBS += -L../BusinessLogic/bin/release -lBusinessLogic
}

假设您的 BusinessLogic/bin/debug 文件夹中有一个 BusinessLogicd.lib,并且 BusinessLogic/bin/release 文件夹中有一个 BusinessLogic.lib。

关于包含路径,我认为只要您位于同一个主项目中,相对路径就可以。

Considering inclusion of different debug/release libraries, you can do the following in the project file:

build_pass:CONFIG(debug, debug|release) {
    LIBS += -L../BusinessLogic/bin/debug -lBusinessLogicd
}
else:build_pass {
    LIBS += -L../BusinessLogic/bin/release -lBusinessLogic
}

This is assuming you have a BusinessLogicd.lib in your BusinessLogic/bin/debug folder and a BusinessLogic.lib in your BusinessLogic/bin/release folder.

Concerning the includepath, I think a relative path is alright as long as you are within the same main project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文