Windows command-line compilation of C files

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.