Qt - Error 2 at compile time(Qt - 编译时出现错误 2)
问题描述
我刚刚下载了 Qt SDK 4.8.1,在安装后,我只是尝试编译一个默认的 C++ 项目,但出现了这个奇怪的错误.
I just downloaded Qt SDK 4.8.1 and, after installing it, I simply tried to compile a default C++ project, but I got this strange error.
16:50:24:运行项目测试的构建步骤...
16:50:24:配置不变,跳过 qmake 步骤.
16:50:24:开始:C:QtSDKQtCreatorinjom.exe"
CL -c -nologo -Zm200 -Zc:wchar_t- -ZI -MDd -GR -EHsc-W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT-I"........QtSDKDesktopQt4.8.1msvc2008includeQtCore" -I"........QtSDKDesktopQt4.8.1msvc2008includeQtGui" -I"........QtSDKDesktopQt4.8.1msvc2008include" -I"........QtSDKDesktopQt4.8.1msvc2008includeActiveQt" -I"debug" -I"."-I".. est" -I"."-I"........QtSDKDesktopQt4.8.1msvc2008mkspecswin32-msvc2008" -Fodebug @C:DOCUME~1dfuserIMPOST~1Tempmain.obj.1464.0.jom
CL -c -nologo -Zm200 -Zc:wchar_t- -ZI -MDd -GR -EHsc-W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT-I"........QtSDKDesktopQt4.8.1msvc2008includeQtCore" -I"........QtSDKDesktopQt4.8.1msvc2008includeQtGui" -I"........QtSDKDesktopQt4.8.1msvc2008include" -I"........QtSDKDesktopQt4.8.1msvc2008includeActiveQt" -I"debug" -I"."-I".. est" -I"."-I"........QtSDKDesktopQt4.8.1msvc2008mkspecswin32-msvc2008" -Fodebug @C:DOCUME~1dfuserIMPOST~1Tempmainwindow.obj.1464.0.jom
C:QtSDKQtCreatorinjom.exe -f Makefile.Debug
jom: C:Documents and SettingsdfuserDesktop est-build-desktop-Qt_4_8_1_for_Desktop_-MSVC2008_Qt_SDK__DebugMakefile.Debug [debugmain.obj] Error 2
16:50:24: Running build steps for project test...
16:50:24: Configuration unchanged, skipping qmake step.
16:50:24: Starting: "C:QtSDKQtCreatorinjom.exe"
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"........QtSDKDesktopQt4.8.1msvc2008includeQtCore" -I"........QtSDKDesktopQt4.8.1msvc2008includeQtGui" -I"........QtSDKDesktopQt4.8.1msvc2008include" -I"........QtSDKDesktopQt4.8.1msvc2008includeActiveQt" -I"debug" -I"." -I".. est" -I"." -I"........QtSDKDesktopQt4.8.1msvc2008mkspecswin32-msvc2008" -Fodebug @C:DOCUME~1dfuserIMPOST~1Tempmain.obj.1464.0.jom
cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I"........QtSDKDesktopQt4.8.1msvc2008includeQtCore" -I"........QtSDKDesktopQt4.8.1msvc2008includeQtGui" -I"........QtSDKDesktopQt4.8.1msvc2008include" -I"........QtSDKDesktopQt4.8.1msvc2008includeActiveQt" -I"debug" -I"." -I".. est" -I"." -I"........QtSDKDesktopQt4.8.1msvc2008mkspecswin32-msvc2008" -Fodebug @C:DOCUME~1dfuserIMPOST~1Tempmainwindow.obj.1464.0.jom
C:QtSDKQtCreatorinjom.exe -f Makefile.Debug
jom: C:Documents and SettingsdfuserDesktop est-build-desktop-Qt_4_8_1_for_Desktop_-MSVC2008_Qt_SDK__DebugMakefile.Debug [debugmain.obj] Error 2
jom 1.0.8 - 增强您的核心能力
jom 1.0.8 - empower your cores
jom: C:Documents and SettingsdfuserDesktop est-build-desktop-Qt_4_8_1_for_Desktop_-MSVC2008_Qt_SDK__DebugMakefile [debug] 错误 2
16:50:24:进程C:QtSDKQtCreatorinjom.exe"退出,代码2.
构建项目测试时出错(目标:桌面)
执行构建步骤Make"时
jom: C:Documents and SettingsdfuserDesktop est-build-desktop-Qt_4_8_1_for_Desktop_-MSVC2008_Qt_SDK__DebugMakefile [debug] Error 2
16:50:24: The process "C:QtSDKQtCreatorinjom.exe" exited with code 2.
Error while building project test (target: Desktop)
When executing build step 'Make'
有人知道是什么原因吗?
Does anyone know what is the cause?
我不知道它是否相关,但在收到此错误之前,我收到了关于 cl
的常见错误,也未找到;我解决了在项目设置中添加到 cl
的路径.
I don't know if it's relevant or not, but before getting this error I got the common error about cl
nor found; I solved adding the path to cl
in the project settings.
推荐答案
我已经解决了:尝试直接执行 cl.exe (C:Program Files (x86)Microsoft Visual Studio 10.0VCincl) 如果您收到 dll 错误,那是因为您的环境设置不正确.所以,你需要在午餐前调用 vcvarsall.bat QtCreator.要每次都这样做,您可以创建一个包含以下内容的 .bat 文件:
I've solved it : try to execute cl.exe directly (C:Program Files (x86)Microsoft Visual Studio 10.0VCincl) if you get a dll error, it's because your environment is not set correctly. So, you need to call vcvarsall.bat before lunch QtCreator. To do that each time, you can create a .bat file which contains the following:
C:Program Files (x86)Microsoft Visual Studio 10.0VCvcvarsall.bat
C:Program Files (x86)Microsoft Visual Studio 10.0VCvcvarsall.bat
{QtCreator 的路径}qtcreator
{Path to QtCreator}qtcreator
(如果您的配置不相同,请更正路径)
(Correct the paths if your configuration is not the same)
你需要执行这个脚本来获取带有正确环境变量的QtCreator,否则会出现dll错误但不报告,你会得到这个错误:2"
You will need to execute this script to get QtCreator with the right environment variables, otherwise, the dll error appears but is not reported, and you get this "Error : 2"
这篇关于Qt - 编译时出现错误 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Qt - 编译时出现错误 2
基础教程推荐
- 使用从字符串中提取的参数调用函数 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 从 std::cin 读取密码 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01