Use gcc in Windows

Source: Internet
Author: User
In Windows, use gcc-general Linux technology-Linux programming and kernel information. The following is a detailed description. Recently, I want to use a program on the linux server in Windows. Directly add souWindowsrce

Codes cannot be compiled using the C compiler of Windows when it is copied to Windows. Some libraries are missing. After

Come on, I think that the files in Linux are compiled with ccgcc. Because of this, I think that if there is a Windows version

Or the ccgcc compiler is worth a try.
After searching for it online for half a day, it seems that there is no ready-made cc or gcc compiler for Windows. However

If Cygwin is used, it can contain the gcc compiler. Cygwin I used it a year or two ago, but not

Too common. Go to the Cygwin website and take a closer look. We found that Cygwin indeed has gcc installed. Then download

Cygwin is installed, and gcc in Cygwin environment is installed. The gcc can be used to compile Linux normally.

Source codes under! Next I will introduce how to install Cygwin and gcc in Windows,

And how to use it.

1. First download an installation file (setup.exe) from the cygwinwebsite (www.cygwin.com.pdf ),

This file is small and only less than kb. Then run setup.exe in double steps. Because it is the first security

Installation, so you must select to install it online from the Internet or download the installation file from the Internet.

And then install it manually. I chose the latter, because in this way, I can install it in the future when it is not connected to the Internet.

2. Click "Next", and select a network rate from the list of servers

The fastest download server. Click "Next" and the page shown in is displayed,

Select the program you want to install.


If you do not make any changes, Cygwin will be installed by default to run the minimum required programs and components. No

The gcc compiler is not in the default installer column, so you must choose to install gcc. Specifically

Expand the Devel directory in the list in the window, find the gcc-g ++ item, and click "Default ".

"Install", and because the program dependency gcc-core entry "Default ",

Changed to "Install ".

In addition, to enable gcc to correctly compile the source file, you must install the win32api library. Otherwise, the source file will be compiled.

Error. Therefore, you need to expand the Libs directory in the preceding window, find win32api, and click it

"Install ".

3. wait patiently for the program to download the required installation file. Once the download is complete

Run setup.exe next time, select the location where Cygwin will be installed, and then select

The hard disk location where the downloaded installation files are located. Then you need to install gcc and

Win32api. In this way, you can start the installation.

4. Run Cygwin after the installation is complete. In the window, you can directly use gcc for compilation by typing gcc.

Compile the executable file generated by the link, and the system will automatically add the .exe suffix. In the Cygwin environment, you can directly

. However, if you run the command in ms dos instead of Cygwin, an error occurs. The solution is simple.

Single, that is, copy the cygwin1.dll file to the C: \ WINDOWS directory.

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.