Qt Creator 中应该如何管理多个项目?
我有一个依赖于多个静态库的 exe,在 Visual Studio 中,它们全部作为 1 个 sln 文件的一部分进行管理,并且该 exe 依赖于静态库。
如何在 Qt Creator 中进行设置?似乎有2个选择: 1. 在 Qt Creator“会话”中创建多个项目。但是会话不在用户之间共享,对吧?所以我不确定这会如何运作?例如,是否有创建的会话文件? 2.使用子项目。并制作exe的静态lib子项目?
有什么建议吗?我对 Qt Creator 完全陌生,需要将其用于 Linux 端口。
谢谢!
I have an exe that depends on multiple static libs and in visual studio, they are all managed as part of 1 sln file and the exe has dependencies on the static libs.
How can this be set up in Qt Creator? Seems like there are 2 options:
1. create multiple projects in a Qt Creator "session". But a session is not shared among users, right? so i'm not sure how that would work? For example, is there a session file that gets created?
2. use subprojects. and make the static lib sub projs of the exe?
Any recommendations? I'm totally new to Qt Creator and need to use it for a linux port.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
要让
qmake
生成一个带有子项目的漂亮.sln
,请使用subdirs
模板创建一个主.pro
文件,并设置每个项目对另一个项目的必要依赖关系。QtCreator 在后台使用 qmake 生成 makefile 并从中构建,但您也可以通过运行生成 VS 解决方案文件。
您还可以使用 Qt Visual Studio 插件来 GUI 化该过程。
另外:为了确保每次更改依赖静态库时都重新链接可执行文件,请使用
将类似的内容放入可执行文件的
.pro
文件中,并注意 LIBSUFFIX 部分是完全可选的,但在与 Qt 本身的构建方式一致,所以我也使用它。请注意 Linux/Mac 版本中缺少的“release”和“debug”子目录。完整地说:相当冗长的if-else
条件是区分debug
和release
的The Right Way (TM)
code> 在 qmake 项目文件中构建。在某些情况下,更简单的方法可能会失败。To get
qmake
to produce a nice.sln
with subprojects, make one main.pro
file with thesubdirs
template, and set the necessary dependencies of each project on another.QtCreator uses
qmake
behind the scenes to generate a makefile and build from that, but you can also produce VS solution files by runningYou can also use the Qt Visual Studio add-in to GUI-ify the process.
Also: to make sure the executable is relinked each time a dependant static lib is changed, use
Place something like this in your executable's
.pro
file, with the note that the LIBSUFFIX part is completely optional, but in line with how Qt itself is built, so that's what I use too. Mind the "release" and "debug" subdirectories absent on Linux/Mac builds. And to be complete: the rather verboseif-else
condition isThe Right Way (TM)
to differentiatedebug
fromrelease
builds in qmake project files. Simpler ways may break under several circumstances.在 Linux 上,会话文件在
~/.config/Nokia/qtcreator
中创建,扩展名为qws
,但我认为这对于多个用户来说并不是一个真正合适的解决方案。On Linux the session files are created in
~/.config/Nokia/qtcreator
, the extension isqws
, but I think this is not a really suitable solution for multiple users.