Today began to revisit the C language programming, pondering the use of the command line to compile C code.
The steps are as follows:
1, first write the following code as shown in Notepad, and save as Hello.cpp, assuming that its save path is
D:cpratice\hello.c.
#include <stdio.h>
Main ()
{
printf ("hello,word!\n");
}
(2) Configuring environment variables (take VS2010 on Win7 as an example)
Right-click Computer-Properties-Advanced system settings-environment variables.
Modify (or add) three environment variables in the following system variables
Path value C:\Program Files\Microsoft Visual Studio 10.0\vc\bin;
Include value C:\Program Files\Microsoft Visual Studio 10.0\vc\include;
Lib value C:\Program Files\Microsoft Visual Studio 10.0\vc\lib;
3. Compile with vs command-line tools, such as:
If you are prompted with an error: "Link:fatal error LNK1104: Unable to open file" LIBCMT.lib ", directory C:\Program Files\Microsoft Visual Studio 10.0\vc\ Copy the LIBCMT.lib file under Lib to the same directory as the C file.
Windows command-line compilation of C files