Use the GNU Compiler in Windows

Source: Internet
Author: User

I. Environment Configuration1. Download and install MinGW

Address http://sourceforge.net/projects/mingw/2. Set the environment variable in the path variable, add the path to the path mingw, such as C: \ Program Files \ MinGW \ bin Ii. Edit source codeAfter using the GNU Compiler in the Windows command line, you can use the command line window in Windows to simulate a Linux terminal. 1. Create the main. c file and run the edit main. c command to create and edit the main. c file. 2. edit the code (ps: Do you remember this simple interface ?) 3. Save and exit. Use the ALT key to call up the menu. Save the file and exit. Iii. compilation process The compilation process consists of four steps: preprocessing, compilation, assembly, and connection. preprocessing preprocessing mainly processes the preprocessing of commands such as "# include" and "# define" in the source file (refer to "Programmer self-cultivation"): (1) delete # define and expand the macro (2) processing condition compilation command. The Preprocessing Program first judges the condition, then modifies the source code based on the condition (3) deletes the comment (4) adds the row number and the file name identifier. Facilitate debugging (5) Delete "# include" and insert the corresponding header file using gcc-E main. c-o main. I command to obtain the main. I file 2. compile and generate the assembly code. Use the gcc-S main. I-o main. s command to compile the main. s file. 3. Compile the assembly code into machine commands. Run the gcc-c main. c-o main. o command to obtain the target file main. o 4. Connect to the database file and convert the target file into an executable file. Using the command gcc-ld, we can directly use gcc main. c-o main to generate executable programs. Of course, when gcc is used in Windows, the generated executable file is no longer main. out, but the main.exe File

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.