Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
186 views
in Technique[技术] by (71.8m points)

c++ - Qt - Error 2 at compile time

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: 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 SettingsdfuserDesktopest-build-desktop-Qt_4_8_1_for_Desktop_-MSVC2008_Qt_SDK__DebugMakefile.Debug [debugmain.obj] Error 2

jom 1.0.8 - empower your cores

jom: C:Documents and SettingsdfuserDesktopest-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?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

{Path to QtCreator}qtcreator

(Correct the paths if your configuration is not the same)

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"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...