Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

qt

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.

like image 433
Vikram Ranabhatt Avatar asked Jan 10 '12 08:01

Vikram Ranabhatt


People also ask

Why is Cl not working in command prompt?

If you see the error "The term 'cl.exe' is not recognized as the name of a cmdlet, function, script file, or operable program.", this usually means you are running VS Code outside of a Developer Command Prompt for Visual Studio and VS Code doesn't know the path to the cl.exe compiler.

What is CL in command line?

CL passes these options to the linker. You can specify any number of options, filenames, and library names, as long as the number of characters on the command line does not exceed 1024, the limit dictated by the operating system.

What is CL in Visual Studio?

cl.exe is a tool that controls the Microsoft C++ (MSVC) C and C++ compilers and linker. cl.exe can be run only on operating systems that support Microsoft Visual Studio for Windows. You can start this tool only from a Visual Studio developer command prompt.


2 Answers

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.

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.

    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.

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

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:

To run 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:

    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:

    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)
like image 173
Smi Avatar answered Oct 14 '22 00:10

Smi


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

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. 
like image 22
Ivar Avatar answered Oct 13 '22 22:10

Ivar