Windows 中的 Qt:构建环境和重新分发问题

发布于 2024-11-29 12:20:36 字数 684 浏览 2 评论 0原文

我想询问您对无休止的“Qt vs wxWidgets”问题的一个具体方面的看法。在 Windows 中使用 wxWidgets,我可以继续使用我喜欢的构建工具和编译器(在我的例子中是 Visual Studio)。我只需要将 wxWidgets include 和 lib 目录添加到编译器/链接器路径中。必要时,我只需打开一些 wxWidgets 表单设计器(如 DialogBlocks)并进行表单布局。可执行文件没有任何额外的依赖项,并且不会在重新分发时引起任何问题。

另一方面,Qt 附带了自己的 IDE,它往往是主要的开发工具(我不想要)。它安装 MinGW。它使用 qmake,这是将 Qt 集成到现有构建环境的又一挑战。我不知道如何在 Qt 应用程序中使用用 VC++ 开发的现有库。我可以继续使用 Visual Studio 还是需要完全切换到 Qt Creator?或者同时使用两者,在 Visual Studio 中构建除 UI 之外的所有内容,并在 Qt Creator 中构建 UI?如何重新分发基于 Qt 的应用程序:我是否需要在目标计算机上安装 MinGW?

如何解决所有这些问题 - 我需要在 Windows 中使用 Qt 的 C++ 开发人员提供一些指导和意见。

编辑:看起来最有前途的方向是 Visual Studio 插件和 CMake。我发现Qt插件支持VS2010,但它需要从源代码重建Qt。对于 VS2008,这个插件可以与二进制 Qt 安装一起使用 - 足够好。

I want to ask your opinion about one specific aspect of endless "Qt vs wxWidgets" question. Using wxWidgets in Windows, I may continue to work with my prefered build tools and compilers (in my case, Visual Studio). I only need to add wxWidgets include and lib directories to the compiler/linker path. When necessary, I just open some wxWidgets form designer (like DialogBlocks) and make form layout. Executables don't have any additional dependencies and don't cause any problems in redistribution.

On the other hand, Qt comes with its own IDE which tends to be the main development tool (which I don't want). It installs MinGW. It uses qmake, this is one more challenge in integrating Qt to existing build environment. I don't know how to use my existing libraries, developed with VC++, in Qt application. Can I continue to work with Visual Studio or I need to switch completely to Qt Creator? Or use both, building everything but UI in Visual Studio, and UI in Qt Creator? How Qt-based application can be redistributed: should I require MinGW installation on target computer?

How all these problems are solved - I need some directions and opinions from C++ developers working with Qt in Windows.

Edit: It looks like most promising directions are Visual Studio plugin and CMake. I found that Qt plugin supports VS2010, but it requires rebuilding Qt from the source. For VS2008 this plugin works with binary Qt installation - good enough.

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

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

发布评论

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

评论(5

似最初 2024-12-06 12:20:36

You don't have to use the whole Qt SDK, you can only install the libraries for VS (or build from source, if you prefer. The pre-built libraries are for VS2008 but there is a makespec for VS2010 so you can build one yourself, if necessary) and use the Visual Studio integration.

给不了的爱 2024-12-06 12:20:36

您可以使用 Visual Studio。有一个 Visual Studio 集成插件,可以让在 Visual Studio 中使用 Qt 进行开发变得更加容易。

至于 wxWidgets 与 Qt 的争论......我两者都使用(在不同的项目上)。我不得不说,我宁愿使用 Qt - 在我看来,它的 bug 更少,而且一般来说,如果您遇到框架问题,有一个更简单的解决方法(Qt4 在这方面比 Qt3 好得多,因为“pimpl”数据是可访问的) )。然而,Qt 的分发稍微复杂一些,因为您必须确保您已在发行版中正确设置包含所有插件(请务必检查它是否可以在未安装 Qt 的干净机器上运行)。

You can use Visual Studio. There is a Visual Studio integration plugin that makes it a lot lot easier to develop with Qt in Visual Studio.

As for the wxWidgets vs Qt debate... I use both (on different projects). I have to say that I would rather use Qt - it has fewer bugs IMO and in general there is an easier workaround if you have problems with the framework (Qt4 is much better in this regard than Qt3 was because the 'pimpl' data is accessible). However, distribution is slightly more complicated with Qt as you must make sure that you have set included any plugins correctly in your distro (be sure to check that it works on a clean machine that does not have Qt installed).

找回味觉 2024-12-06 12:20:36

您可以“仅源”下载 Qt,此处查看最新版本。您可以使用提供的配置工具和 MS 的 nmake 自己构建这个库...

例如,我的典型构建如下所示:

configure -shared -release -opensource -no-webkit -nomake demos -nomake examples
nmake

这将构建发布模式的 Qt dll,假设您想要使用 LGPL 许可证(带有 - opensource flag),没有 webkit 并且在调用 nmake 时它不会构建演示和示例...当然,您必须查看configure提供的所有可能的选项

You can download the Qt "source-only", take a look here for the latest version. You can build this library youself using the provided configure tool and MS' nmake...

For example, my typical build looks like this:

configure -shared -release -opensource -no-webkit -nomake demos -nomake examples
nmake

This will build release-mode Qt dlls, assumes you want to use the LGPL-license (with the -opensource flag), no webkit and upon calling nmake it will not build the demos and examples... Of course, you will have to take a look at all the possible options provided by configure

此生挚爱伱 2024-12-06 12:20:36

您不必使用 Qt Creator,许多人使用其他 IDE 或简单的文本编辑器。

qmake 并不难使用,从模板配置中您可以轻松地手动修改项目文件。事实上,qmake 会生成一个基本的项目文件供您开始使用。

像在任何其他项目中一样使用现有库。

您不需要安装 mingw,您可以在应用程序目录中包含必要的 DLL;但这与任何其他“DLL 地狱”问题是同一个问题。

You don't have to use Qt Creator, many people use other IDEs or simple text editors.

qmake is not difficult to use, from a template config you can easily modify a project file by hand. In fact qmake will generate a basic project file for you to get started with.

Use existing libraries as you would in any other project.

You don't need to require a mingw install, you can include essential DLLs in your application directory; but this is the same problem as any other "DLL hell" problem.

倚栏听风 2024-12-06 12:20:36

如果您使用 cmake 作为构建系统,则可以使用它为 Visual Studio 生成项目文件(以及 Eclipse、普通 Makefile 等,在任何操作系统上)。只需安装 cmake GUI 并在相应的下拉菜单中选择 Visual Studio [myversion]。唯一要记住的是,您需要对 cmake CMakeLists.txt 文件中的项目结构进行更改(例如添加文件)。

设置 cmake + Qt 非常简单,您只需弄清楚一次即可。谷歌搜索一下应该很快就能运行这个设置。

If you use cmake as a build system, you can use that to generate project files for visual studio (and eclipse, and ordinary Makefiles, and ..., on any OS). Just install the cmake GUI and select visual studio [myversion] in the appropriate dropdown menu. The only thing to remember then is that you need to make changes to the structure of your project (e.g. adding files) to the cmake CMakeLists.txt files.

Setting up cmake + Qt is pretty easy, and you only have to figure it out once. Googling around a bit should get this setup running in no time.

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