How to call the VS compiler under the cmd command line of the windows system

Before using gcc under the linux system to compile c files, it is generally compiled and debugged in the form of calling commands from the terminal. Under Windows, we usually use IDE (integrated development environment) such as vs, codeblcoks to compile, debug, execute and other operations. An Integrated Development Environment (IDE) is an application that provides a program development environment, generally including code editors, compilers, debuggers, and graphical user interface tools. It is an integrated development software service suite that integrates code writing functions, analysis functions, compilation functions, and debugging functions. All software or software suites (groups) with this feature can be called integrated development environments (explained from Baidu Encyclopedia). Although it is a whim, can you also use the command line to compile c files in the windows environment. Sure enough, there are such tutorials online. So, give it a try and see how it works. I also posted my own configuration process here for reference only.

I am using win7 Ultimate 64-bit system, vs version 2013. The vs compiler invoked is cl.exe. It seems that it can only be compiled, not debugged. I remember that under linux, gcc is used to compile c files, and gdb is used for debugging. Not sure what the debug command for vs is.

write picture description here
vs2013 is installed in the C:\Program Files (x86)\Microsoft Visual Studio 12.0 directory.
write picture description here
First open the window shown below: Advanced System Settings =====>Environment Variables
write picture description here

In the path variable in the user variable (if not, create a new variable named Path), select Edit, add C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin and C:\ProgramFiles (x86) \Microsoft Visual Studio 12.0\Common7\IDE, separated by English semicolon ";", the former is the directory of cl.exe in the installation directory, the latter is the directory of the dynamic link library file mspdb100.dll (your possible is mspdb60.dll or mspdb80.dll).

write picture description here
3 Create a new variable and add all header files and library files into it:

Create a new lib variable with the value C:\ProgramFiles (x86)\Microsoft Visual Studio 12.0\VC\lib

Create a new include variable with the value C:\ProgramFiles (x86)\Microsoft Visual Studio 12.0\VC\include

If you use the cl command at this time, if you are prompted that the "kernel32.lib" file cannot be opened when connecting, copy the Kernel32.Lib file in the C:\ProgramFiles (x86)\MicrosoftSDKs\Windows\v7.0A\Lib directory to C:\Program Files (x86)\MicrosoftSDKs\Windows\v7.0A\Lib ProgramFiles (x86)\Microsoft Visual Studio 12.0\VC\lib.

At this point it has been configured, use Notepad to write a main.c file, remember to change the suffix name to .c, as shown below
write picture description here

The file is saved under D:\. have a test

Reprinted source: http://blog.csdn.net/qq_31597573/article/details/51220486

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326775758&siteId=291194637