c++qt

'cl' is not recognized as an internal or external command,


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

I am getting 'cl' is not recognized as an internal or external command.

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.

After Setting Env Path = ..;..;C:\Program Files\Microsoft Visual Studio 9.0\VC\bin also it is showing the same error.


Solution

  • That error happens because 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.

    Quoting the article Use the Microsoft C++ toolset from the command line:

    1. On the desktop, open the Windows Start menu. In Windows 11, choose the All apps button to open the list of installed apps. In Windows 10, the list is open to the left. Scroll down the list to find and open the folder (not the app) for your version of Visual Studio, for example, Visual Studio 2022.

    2. In the folder, choose the Developer Command Prompt for your version of Visual Studio. This shortcut starts a developer command prompt window that uses the default build architecture of 32-bit, x86-native tools to build 32-bit, x86-native code. If you prefer a non-default build architecture, choose one of the native or cross tools command prompts to specify the host and target architecture.

    For an even faster way to open a developer command prompt, enter developer command prompt in the desktop search box. Then choose the result you want.

    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:

    1. At the command prompt, use the CD command to change to the Visual Studio installation directory. Then, use CD again to change to the subdirectory that contains the configuration-specific command files. For Visual Studio 2019 and Visual Studio 2017, use the VC\Auxiliary\Build subdirectory. For Visual Studio 2015, use the VC subdirectory.

    2. Enter the command for your preferred developer environment. For example, to build ARM code for UWP on a 64-bit platform, using the latest Windows SDK and Visual Studio compiler toolset, use this command line:

      vcvarsall.bat amd64_arm uwp
      

    From the article, the possible values for the first argument are the following: