如何为 Windows 构建静态 Qt 库并将其与 Qt Creator 一起使用
我已经下载了以下 Qt 源: http://download.qt.nokia .com/qt/source/qt-everywhere-opensource-src-4.7.3.zip 并尝试使用 MS VC 2010 设置带有静态库的发行版。
在此之前,我确实阅读了以下文章:
http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows
http://www.formortals.com/build-qt-static -small-microsoft-intel-gcc-compiler
我修改了 mkspecs\win32-msvc2010\qmake.conf - 更新 QMAKE_CFLAGS_RELEASE 密钥以使用MT 选项而不是 MD。 之后,我从 VC 2010 命令提示符处执行了以下命令行:
configure -platform win32-msvc2010 -static -release
完成后,系统要求我简单地运行 nmake,我照做了。 之后,我尝试将静态库分发文件夹中的 qmake 添加到 Qt Creator(工具/选项 - Qt 部分)。它不成功 - Qt Creator 收到“无法检测 Qt 版本使用的 ABI”消息。
我还尝试(在干净的发行版上)在运行配置命令之前修改 qmake/Makefile.win32 文件 - 将 /MT 选项添加到 CFLAGS_BARE 定义中,但在 Qt Creator 中收到相同的错误消息。
我正在使用 Qt Creator 2.3。 - 单独安装。
我该如何解决这个问题?
I've downloaded the following Qt sources:
http://download.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.7.3.zip
and tried to setup a distribution with static libraries using MS VC 2010.
Beforehand I did read the following articles:
http://www.qtcentre.org/wiki/index.php?title=Building_static_Qt_on_Windows
http://www.formortals.com/build-qt-static-small-microsoft-intel-gcc-compiler
I modified the mkspecs\win32-msvc2010\qmake.conf - update the QMAKE_CFLAGS_RELEASE key to use the MT option instead of MD.
After that I executed the following command line from the VC 2010 command prompt:
configure -platform win32-msvc2010 -static -release
When that has finished I was asked to simply run nmake, which I did.
After that I tried to add the qmake from the the static libs distribution folder to Qt Creator (Tools/Options - Qt section). It was unsuccessful - got "Failed to detect ABI(s) used by the Qt version" message by Qt Creator.
I also tried (on a clean distribution) modifying the qmake/Makefile.win32 file before running the configure command - added /MT option to the CFLAGS_BARE definition, but got the same error message in Qt Creator.
I'm using Qt Creator 2.3. - installed separately.
How can I solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您使用的是 2.3 稳定版还是 Qt Creator 的候选版/测试版?检查“帮助”->“关于 Qt Creator”了解版本。如果是类似 2.x.xx 的内容,请尝试更新到较新版本的 Qt Creator。
您描述的问题被列为 2.2.0 的错误,并设置为已修复 2.3.0:
https://bugreports.qt.io/browse/QTCREATORBUG-4771
如果您已经使用较新的版本但仍然遇到该问题,我读过一些关于将 QtCore4.dll 放在 .lib 文件旁边的内容。然后,Qt Creator 将找到基于该 dll 的 Qt 版本,但无论如何都会使用 .libs 进行链接。
Are you using the stable release of 2.3 or a release candidate / beta version of Qt Creator? Check Help->About Qt Creator for the version. If it is something like 2.x.xx try updating to a newer version of Qt Creator.
The issue you described was listed as a bug for 2.2.0 and was set to fixed for 2.3.0:
https://bugreports.qt.io/browse/QTCREATORBUG-4771
If you are already using a newer version and still have that issue, I've read something about putting a QtCore4.dll next to the .lib files. Qt Creator will then find the Qt version based on that dll, but will use the .libs for linking anyway.