“cl”不被视为内部或外部命令,

时间:2021-10-25 23:10:04

I am trying to compile a hello world program in Qt Using Qt Creator.

我正在尝试用Qt的创建者在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\ VC\bin也显示了相同的错误。

9 个解决方案

#1


36  

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不在你的路上。你需要把它加进去。推荐的方法是启动一个developer命令提示符。

Quoting the article Setting the Path and Environment Variables for Command-Line Builds:

引用为命令行构建设置路径和环境变量的文章:

To open a Developer Command Prompt window

打开开发人员命令提示符窗口。

  1. With the Windows 8 Start screen showing, type Visual Studio Tools. Notice that the search results change as you type; when Visual Studio Tools appears, choose it.

    在显示Windows 8开始屏幕时,输入Visual Studio工具。注意,搜索结果会随着您的输入而改变;当Visual Studio工具出现时,选择它。

    On earlier versions of Windows, choose Start, and then in the search box, type Visual Studio Tools. When Visual Studio Tools appears in the search results, choose it.

    在Windows的早期版本中,选择Start,然后在搜索框中输入Visual Studio工具。当Visual Studio工具出现在搜索结果中时,选择它。

  2. In the Visual Studio Tools folder, open the Developer Command Prompt for your version of Visual Studio. (To run as administrator, open the shortcut menu for the Developer Command Prompt and choose Run as Administrator.)

    在Visual Studio Tools文件夹中,打开Visual Studio的Developer命令提示符。(以管理员身份运行,为开发人员命令提示打开快捷菜单,并选择run作为管理员。)

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。使用适当的参数设置环境变量。引用同一篇文章:

To run vcvarsall.bat

运行vcvarsall.bat

  1. 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:

    在命令提示符下,更改为Visual c++安装目录。(位置取决于系统和Visual Studio安装,但一个典型的位置是\ VC C:\Program Files (x86)\Microsoft Visual Studio版本。)例如,输入:

    cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
    
  2. To configure this Command Prompt window for 32-bit x86 command-line builds, at the command prompt, enter:

    要为32位x86命令行构建配置此命令提示窗口,请在命令提示符下输入:

    vcvarsall x86
    

From the article, the possible arguments are the following:

从这篇文章中,可能的论点如下:

  • x86 (x86 32-bit native)
  • x86(32位x86本地)
  • x86_amd64 (x64 on x86 cross)
  • x86_amd64 (x86交叉上的x64)
  • x86_arm (ARM on x86 cross)
  • x86_arm (x86交叉上的ARM)
  • amd64 (x64 64-bit native)
  • amd64(x64 64位本地)
  • amd64_x86 (x86 on x64 cross)
  • amd64_x86 (x86 on x64 cross)
  • amd64_arm (ARM on x64 cross)
  • amd64_arm (x64横臂)

#2


6  

I had the same problem. Try to make a bat-file to start the Qt Creator. Add something like this to the bat-file:

我也有同样的问题。尝试创建一个批处理文件来启动Qt创建程序。在批文件中添加如下内容:

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.

#3


3  

Make sure you restart your computer after you install the Build Tools.

确保在安装构建工具后重新启动计算机。

This was what was causing the error for me.

这就是我犯错的原因。

#4


2  

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来构建应用程序。

#5


1  

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++.

从左窗格中选择Project选项卡。然后选择“目标”。从那里把Qt版本改为MinGW而不是vc++。

#6


1  

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://*.com/a/31568246/1054322

要添加它,请参见:https://*.com/a/31568246/1054322

#7


0  

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\System32 to Path variable under User Variables in 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在用户变量在环境变量Path变量……注意,如果您将它添加到系统变量中,它也可以工作。但是,这对我不起作用。

#8


0  

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所在的路径。使用“引导。bat“,你可以成功安装它。

#9


0  

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找不到通用工具目录。

#1


36  

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不在你的路上。你需要把它加进去。推荐的方法是启动一个developer命令提示符。

Quoting the article Setting the Path and Environment Variables for Command-Line Builds:

引用为命令行构建设置路径和环境变量的文章:

To open a Developer Command Prompt window

打开开发人员命令提示符窗口。

  1. With the Windows 8 Start screen showing, type Visual Studio Tools. Notice that the search results change as you type; when Visual Studio Tools appears, choose it.

    在显示Windows 8开始屏幕时,输入Visual Studio工具。注意,搜索结果会随着您的输入而改变;当Visual Studio工具出现时,选择它。

    On earlier versions of Windows, choose Start, and then in the search box, type Visual Studio Tools. When Visual Studio Tools appears in the search results, choose it.

    在Windows的早期版本中,选择Start,然后在搜索框中输入Visual Studio工具。当Visual Studio工具出现在搜索结果中时,选择它。

  2. In the Visual Studio Tools folder, open the Developer Command Prompt for your version of Visual Studio. (To run as administrator, open the shortcut menu for the Developer Command Prompt and choose Run as Administrator.)

    在Visual Studio Tools文件夹中,打开Visual Studio的Developer命令提示符。(以管理员身份运行,为开发人员命令提示打开快捷菜单,并选择run作为管理员。)

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。使用适当的参数设置环境变量。引用同一篇文章:

To run vcvarsall.bat

运行vcvarsall.bat

  1. 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:

    在命令提示符下,更改为Visual c++安装目录。(位置取决于系统和Visual Studio安装,但一个典型的位置是\ VC C:\Program Files (x86)\Microsoft Visual Studio版本。)例如,输入:

    cd "\Program Files (x86)\Microsoft Visual Studio 12.0\VC"
    
  2. To configure this Command Prompt window for 32-bit x86 command-line builds, at the command prompt, enter:

    要为32位x86命令行构建配置此命令提示窗口,请在命令提示符下输入:

    vcvarsall x86
    

From the article, the possible arguments are the following:

从这篇文章中,可能的论点如下:

  • x86 (x86 32-bit native)
  • x86(32位x86本地)
  • x86_amd64 (x64 on x86 cross)
  • x86_amd64 (x86交叉上的x64)
  • x86_arm (ARM on x86 cross)
  • x86_arm (x86交叉上的ARM)
  • amd64 (x64 64-bit native)
  • amd64(x64 64位本地)
  • amd64_x86 (x86 on x64 cross)
  • amd64_x86 (x86 on x64 cross)
  • amd64_arm (ARM on x64 cross)
  • amd64_arm (x64横臂)

#2


6  

I had the same problem. Try to make a bat-file to start the Qt Creator. Add something like this to the bat-file:

我也有同样的问题。尝试创建一个批处理文件来启动Qt创建程序。在批文件中添加如下内容:

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.

#3


3  

Make sure you restart your computer after you install the Build Tools.

确保在安装构建工具后重新启动计算机。

This was what was causing the error for me.

这就是我犯错的原因。

#4


2  

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来构建应用程序。

#5


1  

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++.

从左窗格中选择Project选项卡。然后选择“目标”。从那里把Qt版本改为MinGW而不是vc++。

#6


1  

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://*.com/a/31568246/1054322

要添加它,请参见:https://*.com/a/31568246/1054322

#7


0  

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\System32 to Path variable under User Variables in 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在用户变量在环境变量Path变量……注意,如果您将它添加到系统变量中,它也可以工作。但是,这对我不起作用。

#8


0  

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所在的路径。使用“引导。bat“,你可以成功安装它。

#9


0  

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找不到通用工具目录。