windows windows上的qt配置
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/500701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
qt configuration on windows
提问by hasen
I'm having some trouble installing and configuring qt on my vista laptop.
我在 vista 笔记本电脑上安装和配置 qt 时遇到了一些问题。
I'm trying to setup a development environment on my laptop where I compile from the command line, because that's how the environment is setup on my university's linux machines, so I don't want to tie myself to some IDE .. (plus, realprogrammers use the command line!)
我试图在我的笔记本电脑上设置一个开发环境,我从命令行编译,因为这就是我大学的 linux 机器上的环境设置方式,所以我不想将自己绑定到某些 IDE ..(另外,真正的程序员使用命令行!)
I haven't used the command line before for C++ development, it was all MSVC, so now I'm having a bit of trouble.
我之前没有使用命令行进行C++开发,都是MSVC,所以现在有点麻烦。
I'm still using MSVC, but from the command line. I practically have no idea what's going on, I just know that I have to run:
我仍在使用 MSVC,但来自命令行。我几乎不知道发生了什么,我只知道我必须运行:
qmake
nmake
to compile my code!
编译我的代码!
I downloaded the opensource version of qt, and did the configuration, and tried a simple qt application (from a tutorial) and it worked, it compiled and executed pretty much as expected.
我下载了 qt 的开源版本,并进行了配置,并尝试了一个简单的 qt 应用程序(来自教程)并且它工作正常,它几乎按预期编译和执行。
Now, when I decided to run another project that uses opengl, I got the following error:
现在,当我决定运行另一个使用 opengl 的项目时,出现以下错误:
fatal error C1083: Cannot open include file: 'qgl.h': No such file
or directory
I'm not sure where does the compiler look for header files, and I didn't copy any header files anywhere, I assume that configure.exe
worked its magic somehow and added the include directory to one or more enviroment variables or to some registery location or whatever other peculier places that the MSVC compiler searches for to find include directories.
我不确定编译器在哪里查找头文件,而且我没有在任何地方复制任何头文件,我认为这configure.exe
以某种方式发挥了它的魔力,并将包含目录添加到一个或多个环境变量或某个注册位置或其他任何位置MSVC 编译器搜索以查找包含目录的其他特殊位置。
However, what I did was search my C:\qt\include\
folder to make sure that qgl.h
exists, and sure enough there it was. so why can't nmake
find it?
但是,我所做的是搜索我的C:\qt\include\
文件夹以确保它qgl.h
存在,并且确实存在。那为什么nmake
找不到呢?
回答by mxcl
I think the actual solution to this is in your pro file:
我认为对此的实际解决方案在您的专业文件中:
QT += opengl
QT += opengl
回答by Hendy Irawan
Install the complete Qt SDK for Windowswhich includes Qt 4.6 SDK, Qt Creator 1.3, and MinGW.
安装完整的 Windows 版 Qt SDK,其中包括 Qt 4.6 SDK、Qt Creator 1.3 和 MinGW。
It will also install "Qt Command Prompt" launcher that you can use to build Qt apps from the command line.
它还将安装“Qt 命令提示符”启动器,您可以使用它从命令行构建 Qt 应用程序。
I'm sure you're more familiar with MSVC than MinGW, as I do too (I've been using MSVC 6.0 to MSVC# 2008 for developing .NET apps).
我相信您比 MinGW 更熟悉 MSVC,我也是(我一直在使用 MSVC 6.0 到 MSVC# 2008 来开发 .NET 应用程序)。
But try MinGW with Qt and I think it's better for long term. I do some C++ development on Linux too so getting familiar with MinGW will be beneficial for you in cross-platform C++/Qt development.
但是尝试使用 Qt 的 MinGW,我认为从长远来看会更好。我也在 Linux 上进行了一些 C++ 开发,因此熟悉 MinGW 将有助于您进行跨平台 C++/Qt 开发。
For more info, see Installation of Qt 4.6 SDK for Windows.
有关详细信息,请参阅Windows 版 Qt 4.6 SDK 的安装。
回答by bluebrother
If you want to stay with the command line anyway (plus use it on a linux box later / parallel) I'd suggest at least trying out the MinGW version of Qt. I'm using it regularly, and besides of the non-existance of a GUI it works pretty well. Using MinGW also has the advantage that you can simply download and install the MinGW edition of Qt and don't need to reconfigure or recompile anything.
如果您无论如何都想继续使用命令行(加上稍后在 linux 机器上/并行使用它),我建议至少尝试使用 Qt 的 MinGW 版本。我经常使用它,除了不存在 GUI 之外,它运行良好。使用MinGW还有一个好处,就是可以简单的下载安装Qt的MinGW版本,不需要重新配置或重新编译任何东西。
Also, trying out QtCreatormight be interesting. It's still beta and requires the beta Qt 4.5 but it's a nice small IDE that integrates nicely with gcc.
此外,尝试QtCreator可能会很有趣。它仍然是测试版,需要测试版 Qt 4.5 但它是一个不错的小型 IDE,可以很好地与 gcc 集成。
回答by bluebrother
Two potential solutions (they solved issues at my workplace)
两个潜在的解决方案(他们解决了我工作场所的问题)
Do you have qt include and bin folders in the PATH variable? I think the doc says only one of these is needed, but one of the students had Vista and putting the other in the PATH variable solved a "Cannot open include file" problem.
你有 PATH 变量中的 qt include 和 bin 文件夹吗?我认为文档说只需要其中一个,但是其中一个学生拥有 Vista 并将另一个放在 PATH 变量中解决了“无法打开包含文件”的问题。
If you're using MSVC did you run configure and nmake from the Visual Studio command prompt? We had problems when using the bare windows Command Prompt because the VS one adds a lot of temporary environment variables to the configure process.
如果您使用的是 MSVC,您是否从 Visual Studio 命令提示符运行了 configure 和 nmake?我们在使用裸 Windows 命令提示符时遇到了问题,因为 VS 向配置过程添加了许多临时环境变量。
Good luck
祝你好运
回答by bluebrother
The opensource version of Qt does not provide profiles (mkspecs in qt terms) so qmake can generate nmake (msvc) compatible makefiles.
Qt 的开源版本不提供配置文件(qt 术语中的 mkspecs),因此 qmake 可以生成与 nmake (msvc) 兼容的 makefile。
You have to use mingw/gcc.
你必须使用 mingw/gcc。
回答by Jacek ?awrynowicz
Qmake generates Makefile from *.pro file located in current directory. It has qt path compiled in. Type "qmake -v" to see it. You can't move qt's dir after compiling it. If You haven't moved it, first maybe try to install Qt following instruction from INSTALL file. Good luck.
Qmake 从位于当前目录的 *.pro 文件生成 Makefile。它已经编译了 qt 路径。输入“qmake -v”来查看它。编译后不能移动qt的目录。如果您还没有移动它,请首先尝试按照 INSTALL 文件中的说明安装 Qt。祝你好运。