1

In GCC, I just need to set the MinGW/bin path to use it from the command line... But how to use MSVC from the command line? I don't want to create a project folder. In GCC, I don't need to specify/create any project folder; I just need to set the path in environment variables. But how to do this for MSVC so that I can use it from the command line? Can anyone help me in this case?

Operating System: Windows 7

1 Answer 1

1

The MSVC compiler is named cl.exe and can be called via the command line.

You need to ensure that its folder is found in the PATH, where it should already have been included by the installation. Typically, this folder is in the subfolder VC\bin or VC\Tools\MSVC, depending on the Visual Studio version. You may need to search for the file cl.exe to find its exact path.

Information on using CL can be found in the article Compiler Command-Line Syntax.

5
  • In my case, the path is D:\IDE\Visual Studio\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\Hostx86\x86. And when I tried this I found this error... hello.cpp hello.cpp(1): fatal error C1034: iostream: no include path set D:\> Commented May 31, 2021 at 13:50
  • 1
    Visual Studio adds all the required parameters to the call from the specifications of the project. In your case, since you have chosen to call CL directly, it's up to you to specify them. For example, you might need to specify the include folder with the parameter of /I. For finding out all required parameters, it might be better to setup a project, then copy the CL command that is generated.
    – harrymc
    Commented May 31, 2021 at 13:56
  • Oh thanks, @harrymc but what did you mean by "it might be better to setup a project, then copy the CL commans that is generated"? Where is the CL command that I should copy? And are you saying that I should create a project in Visual Studio by saying this"it might be better to setup project"? Commented May 31, 2021 at 14:52
  • However /I compiler flag also gave error. Commented May 31, 2021 at 15:09
  • The Windows CL compiler is not as easy to call as in Linux, so having an example is useful.
    – harrymc
    Commented May 31, 2021 at 15:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .