C++ 'cl' 不被识别为内部或外部命令,
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8800361/
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
'cl' is not recognized as an internal or external command,
提问by Chris_vr
I am trying to compile a hello world program in Qt Using Qt Creator.
我正在尝试使用 Qt Creator 在 Qt 中编译一个 hello world 程序。
I am getting 'cl' is not recognized as an internal or external command.
我收到 'cl' 未被识别为内部或外部命令。
I am using Windows 7 and Both Vs 2008 and 2010 installed in it. When I use Mingw it is compiling fine but if use vs 2008 it is giving this error.
我正在使用 Windows 7 和安装在其中的两个 Vs 2008 和 2010。当我使用 Mingw 时,它编译良好,但如果使用 vs 2008,则会出现此错误。
After Setting Env Path =..;..;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin also it is showing the same error.
设置 Env Path =..;..;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin 后,它也显示相同的错误。
采纳答案by Smi
I think cl
isn't in your path. You need to add it there. The recommended way to do this is to launch a developer command prompt.
我认为cl
不在你的道路上。你需要在那里添加它。推荐的方法是启动开发人员命令提示符。
Quoting the article Setting the Path and Environment Variables for Command-Line Builds:
引用文章为命令行构建设置路径和环境变量:
To open a Developer Command Prompt window
With the Windows 8 Start screen showing, type Visual Studio Tools. Notice that the search results change as you type; when Visual Studio Toolsappears, choose it.
On earlier versions of Windows, choose Start, and then in the search box, type Visual Studio Tools. When Visual Studio Toolsappears in the search results, choose it.
In the Visual Studio Toolsfolder, open the Developer Command Promptfor your version of Visual Studio. (To run as administrator, open the shortcut menu for the Developer Command Prompt and choose Run as Administrator.)
打开开发人员命令提示符窗口
在显示 Windows 8 开始屏幕的情况下,键入Visual Studio Tools。请注意,搜索结果会随着您的输入而变化;当Visual Studio Tools出现时,选择它。
在早期版本的 Windows 上,选择“开始”,然后在搜索框中键入Visual Studio Tools。当Visual Studio Tools出现在搜索结果中时,选择它。
在Visual Studio 工具文件夹中,打开适用于您的 Visual Studio 版本的开发人员命令提示符。(要以管理员身份运行,打开 Developer Command Prompt 的快捷菜单并选择Run as Administrator。)
As the article notes, there are several different shortcuts for setting up different toolsets - you need to pick the suitable one.
正如文章所指出的,设置不同的工具集有几种不同的快捷方式 - 您需要选择合适的一种。
If you already have a plain Command Prompt window open, you can run the batch file vcvarsall.bat
with the appropriate argument to set up the environment variables. Quoting the same article:
如果您已经打开了一个普通的命令提示符窗口,您可以vcvarsall.bat
使用适当的参数运行批处理文件来设置环境变量。引用同一篇文章:
To run vcvarsall.bat
At the command prompt, change to the Visual C++ installation directory. (The location depends on the system and the Visual Studio installation, but a typical location is C:\Program Files (x86)\Microsoft Visual Studio version\VC.) For example, enter:
cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
To configure this Command Prompt window for 32-bit x86 command-line builds, at the command prompt, enter:
vcvarsall x86
运行 vcvarsall.bat
在命令提示符处,切换到 Visual C++ 安装目录。(位置取决于系统和 Visual Studio 安装,但典型位置为 C:\Program Files (x86)\Microsoft Visual Studio version\VC。)例如,输入:
cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
要为 32 位 x86 命令行构建配置此命令提示符窗口,请在命令提示符下输入:
vcvarsall x86
From the article, the possible arguments are the following:
从文章中,可能的论点如下:
x86
(x86 32-bit native)x86_amd64
(x64 on x86 cross)x86_arm
(ARM on x86 cross)amd64
(x64 64-bit native)amd64_x86
(x86 on x64 cross)amd64_arm
(ARM on x64 cross)
x86
(x86 32 位本机)x86_amd64
(x86 交叉上的 x64)x86_arm
(ARM 上 x86 交叉)amd64
(x64 64 位本机)amd64_x86
(x64 交叉上的 x86)amd64_arm
(ARM 上 x64 交叉)
回答by Ivar
I had the same problem. Try to make a bat-file to start the Qt Creator. Add something like this to the bat-file:
我有同样的问题。尝试制作一个 bat 文件来启动 Qt Creator。将这样的内容添加到 bat 文件中:
call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
"C:\QTsdk\qtcreator\bin\qtcreator"
Now I can compile and get:
现在我可以编译并得到:
jom 1.0.8 - empower your cores
11:10:08: The process "C:\QTsdk\qtcreator\bin\jom.exe" exited normally.
回答by DunskyDouglas
Make sure you restart your computer after you install the Build Tools.
确保在安装构建工具后重新启动计算机。
This was what was causing the error for me.
这就是导致我出错的原因。
回答by Jubayer Arefin
I had the same problem and I solved it by switching to MinGW from MSVC2010.
我遇到了同样的问题,我通过从 MSVC2010 切换到 MinGW 来解决它。
Select the Project Tab from your left pane. Then select the "Target". From there change Qt version to MinGW instead of VC++.
从左窗格中选择“项目”选项卡。然后选择“目标”。从那里将 Qt 版本更改为 MinGW 而不是 VC++。
回答by Bo Persson
You will have to set environmental variables properly for each compiler. There are commands on your Program menu for each compiler that does that, while opening a command prompt.
您必须为每个编译器正确设置环境变量。在打开命令提示符时,每个编译器的程序菜单上都有执行此操作的命令。
Another option is of course to use the IDE for building your application.
当然,另一种选择是使用 IDE 来构建应用程序。
回答by nmnm
I had the same issue for a long time and I spent God knows how much on it until I accidentally figured what to do. This solution worked on windows 10. All you need to do is to add C:\WINDOWS\System32to Pathvariable under User Variablesin Environmental Variables... Note that if you add this to the system variables, it may also work. But, that didn't work for me.
我有很长一段时间都遇到同样的问题,天知道我花了多少时间,直到我不小心想出了该怎么做。该解决方案的工作在Windows 10,所有你需要做的就是添加C:\ Windows \ System32下到路径下的变量用户变量中的环境变量..。请注意,如果将其添加到系统变量中,它也可能起作用。但是,这对我不起作用。
回答by MatrixManAtYrService
I had this problem because I forgot to select "Visual C++" when I was installing Visual Studio.
我遇到这个问题是因为我在安装 Visual Studio 时忘记选择“Visual C++”。
To add it, see: https://stackoverflow.com/a/31568246/1054322
要添加它,请参阅:https: //stackoverflow.com/a/31568246/1054322
回答by Lily
You can use Command prompt for VS 2010 and then select the path that your boost located. Use "bootstrap.bat", you can successfully install it.
您可以使用 VS 2010 的命令提示符,然后选择您的 boost 所在的路径。使用“bootstrap.bat”,即可成功安装。
回答by user3898942
For me, this was related to the scenario described by Smi, with the difference being that vcvarsall.bat
itself was failing due to an invalid path.
This was cause by line-breaks within the path, which meant vcvarsall.bat
couldn't find the common tools directory for some reason.
对我来说,这与 Smi 描述的场景有关,不同之处在于它vcvarsall.bat
本身由于路径无效而失败。
这是由路径中的换行符引起的,这意味着vcvarsall.bat
由于某种原因无法找到通用工具目录。
回答by mathiasfk
I sometimes get this problem when changing from Debug to Release or vice-versa. Closing and reopening QtCreator and building again solves the problem for me.
从 Debug 更改为 Release 或反之亦然时,我有时会遇到此问题。关闭并重新打开 QtCreator 并再次构建为我解决了问题。
Qt Creator 2.8.1; Qt 5.1.1 (MSVC2010, 32bit)
Qt Creator 2.8.1;Qt 5.1.1(MSVC2010,32 位)