Using the command line formerly seemed to be a nerd thing, but over time it was noticed that it is much more practical and easier than the graphical mode, in addition to having a Huge performance gain!
In this article we will see that you can use the cl
command from the MSVC compiler from Microsoft to compile your programs!
ATTENTION
Pictures are not in English, but you can understand how the corresponding path in your language!
First of all make sure you have Visual Studio installed.
After creating your project, which does not necessarily need to have been created in Visual Studio, it can be in VS Code, Vim, Code::Blocks and others.
To compile, just search for the word Developer PowerShell in the Windows Start Bar and choose the option: Developer PowerShell for VS 2019, remembering that in this case refers to the 2019 version of Visual Studio, but if you have the other version, the year/version number will appear. And click Open.
In the image there is the use of the commands cd
, ls
and cat
by PowerShell, but use Developer PowerShell.
To compile just use the cl
command, as shown below:
And then to run, run the file name with a backslash:
You can also create any binary name you like similar to GCC and Clang:
There are also other parameters, however, the model used by MSCV is not always the use of dash -
but a slash, example for Wall
, O2
and others:
For more parameters run the command:
You can also open Developer PowerShell or even CMD
through Visual Studio, saving time-consuming use of the Graphical Debugger.
To do this, just click on: Tools
> Command Line
> Developer PowerShell
or Developer Command Prompt
:
And use the same procedures listed above:
For more information go to: MSVC address.