如何在 Visual Studio 2010 中设置 Qt 路径?
我刚刚下载并安装了最新版本的 Qt SDK、Qt Creator 和 Visual Studio 的 Qt 插件(我运行的是 VS 2010)。
首先,我尝试在VS2010中创建一个Qt项目。它想出了
无法找到 Qt 版本!
要解决此问题,请指定 Qt 构建
所以我转到 Qt -> VS 中的 Qt 选项菜单项,然后单击添加版本。
现在,我有 2 个 qmake.exe 文件:一个在 C:\Qt\2010.05\qt\qmake 中,一个在 C:\Qt\2010.05\qt\bin 中
出于某种原因,如果我选择这些文件之一,它就会出现出现错误消息,该版本的 Qt 是使用 MingW 构建的。 (我不明白为什么编译它会产生影响,只要编译它就行?)
在花了一些时间尝试为 VS 插件找到一个可用的 qmake.exe 之后,我放弃了并尝试获取原始版本Qt 创建者来工作。
Qt Creator 也未配置为与自身一起运行(笑)。 当我选择两个 qmake.exe 文件中的任何一个的路径时,当我尝试编译一个小程序时,它会出现一条错误消息:
找不到 make 命令:在构建环境中 make
构建无标题项目时出错(目标:桌面)
执行构建步骤“Make”时
时当我检查 Qt 创建者中的选项时,它说 qmake 的版本为 4.7.0,并且
Qt版本未正确安装,请运行make install
VS2010 插件已安装到我的 Program Files (x86) 文件夹中,但那里没有 qmake.exe 文件。
我运行的是 Windows 7 x64。
I just downloaded and installed the latest versions of the Qt SDK, Qt Creator, and the Qt add-in for Visual Studio (I'm running VS 2010).
First, I tried creating a Qt project in VS2010. It came up with
Unable to find a Qt build!
To solve this problem specify a Qt build
So I go to the Qt -> Qt Options menu item in VS and click Add for the version.
Now, I have 2 qmake.exe files: one in C:\Qt\2010.05\qt\qmake and one in C:\Qt\2010.05\qt\bin
For some reason, if I select either one of these files, it comes up with the error message the this version of Qt was built with MingW. (I don't see why it makes a difference what compiled it, just so long as it's compiled?)
After spending some time trying to find a working qmake.exe for the VS add-in I gave up and tried to get the original Qt creator to work instead.
Qt creator is also not configured to run with itself (lol).
When I select the path to either of my 2 qmake.exe files, it comes up with an error message when I try to compile a small program:
Could not find make command: make in the build environment
Error while building project untitled (target: Desktop)
When executing build step 'Make'
When I check the options in Qt creator, it says qmake is at version 4.7.0 and that
Qt version is not properly installed, please run make install
The VS2010 add-in is installed to my program files (x86) folder, but there are no qmake.exe files there.
I'm running Windows 7 x64.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我几乎肯定您必须先在 Visual Studio 中重建 Qt 库,然后才能使用它们。这可能解释了为什么您会收到无法找到 Qt 版本的错误消息,并且您正在使用的 Qt 版本是使用 MinGW 构建的。
我建议阅读这个博客文章 看起来是关于将 Qt 与 VS 集成的可靠操作指南。
这看起来像是一个更简单的指南,尽管它是 PDF 格式:Qt Installation for Visual Studio
I'm almost positive that you have to rebuild the Qt libraries in Visual Studio first before you can use them. That probably explains why you're getting the error message that a Qt build can't be found, and that the version of Qt you're using was built with MinGW.
I suggest reading this blog post for what looks to be a solid how-to guide on integrating Qt with VS.
This looks like an even simpler guide, although it's in PDF format: Qt Installation for Visual Studio
用vs2010重新构建它,它更容易,并且允许您在调试时进入Qt src。
在 Qt src 树的顶部做
配置-no-webkit -no-qt3support -opensource -platform win32-msvc2010
(webkit是可选的,但构建需要很长时间)
将构建一个.sln文件,您可以在VS2010中打开并构建
Rebuild it with vs2010, it's much easier, and allows you to step into the Qt src in debug.
In the top of the Qt src tree do
configure -no-webkit -no-qt3support -opensource -platform win32-msvc2010
(webkit is optional but it takes a long time to build)
Will build a .sln file which you can open in VS2010 and build
首先,MinGW 库不能与 Visual Studio 一起使用是很正常的。如果您仍然生气,请阅读该主题。
Qt SDK(如果您下载的是它,则应附带预装的 QtCreator,只需最少的设置或无需设置即可与随附的 MinGW 工具链一起使用。
如果您想将 Visual Studio 与加载项一起使用,则需要尝试从此网页下载Visual Studio 2008或自己重建Qt 这并不难,只是。将加载项指向其中任何一个的构建或安装位置应该可以让您继续。
Firstly, it's quite normal that MinGW libraries don't work with Visual Studio. Read up on the subject if you're still angry.
The Qt SDK (if that's what you downloaded, should come with a pre-installed QtCreator that works with minimal or no setup with the included MinGW toolchain.
If you want to use Visual Studio with the add-in, you'll need to either try the Visual Studio 2008 download from this webpage or rebuild Qt yourself. It's not hard, just time-consuming. Pointing the add-in to the build or install location of either of those should get you going.
当您之前安装了旧版本的 Qt 时,即使您努力卸载它们,Trolltech 的注册表项仍将包含旧值。要解决此问题,请启动注册表编辑器 (regedit.exe),滚动到:
HKEY_CURRENT_USER\Software\Trolltech\Versions\DefaultQtVersion
并将其编辑为当前版本号。检查 Trolltech 组中的其他条目,确保它们设置为当前版本。
的问题
这解决了
Unable to find a Qt build! !为了解决这个问题,请为我指定一个 Qt 构建
。
When you had older versions of Qt installed before, even if you uninstall them diligently, registry entry for Trolltech will still contain old values. To fix that, start Registry Editor (regedit.exe), scroll to:
HKEY_CURRENT_USER\Software\Trolltech\Versions\DefaultQtVersion
and edit it to current version number. Check other entries in Trolltech group, to make sure they are set to current version.
That solved the problem of
Unable to find a Qt build! To solve this problem specify a Qt build
for me.