How to Install GCC Compiler with a Terminal on the Windows Operating System


Posted on 12 June 2016

In this article, you will find the steps to install a GCC Compiler on you Windows Operating System.

Step 1 -Download the Cygwin Package Installer:

1) Download the Cygwin installer from this link. You can choose the 32-bit or the 64-bit installer as per your requirement.

Open the setup file after downloading and follow the remaining steps ?

1) When the following window appears, choose 'Install from Internet' and click Next.

2) In the next window, select 'Direct Connection'. Click on Next button.

3) When the installer prompts you to choose Download sites, simply select the first option and click on Next.

4) Follow next steps and finish the installation.

Note : Proceed to Step 2 only after the final installation in Step 1 is completely over. This may take a couple of minutes.

Step 2 - Install the Packages.

1) After installing, copy the setup file (from Downloads) into the following directory C:>>cygwin64 (there will be a folder named 'cygwin64' in Local Disk C:). Open the command prompt on Windows (search for 'Command Prompt' in the Start Menu.) and run the following commands. Each of them may take several minutes to complete. You can directly copy and paste the commands rather than typing them.

>> cd\cygwin64
>> setup-x86_64.exe -q -P wget -P gcc-g++ -P make -P diffutils -P libmpfr-devel -P libgmp-devel -P libmpc-devel

This will open a new pop up which will install all the required packages over a course of time. Make sure you are connected to the internet before you proceed to Step 3.

Step 3 - Configure the GCC Compiler

1) Once all the packages are installed, open the Cygwin64 teminal from your desktop screen or from the root directory.
Copy and paste the following command into it .

>> wget

After entering the above command the terminal will start configuring and installs the source code files automatically. 
Now, type the following command into the terminal.

>> tar xf gcc-4.9.2.tar.gz

Above command will take upto 15 mins on an average Broadband connection.
So please be patient.
Now run these 3 commands one by one.

>> mkdir build-gcc
>> cd build-gcc
>> ../gcc-4.9.2/configure --program-suffix=-4.9.2 --enable languages=c,c++ --disable-bootstrap --disable-shared

Now run

>> make -j4

The above command will take upto 10 minutes to get executed.

>> make install
>> cd ..

Your compiler is successfully configured now.

Step 4 - Run your code on the GCC Compiler

1) Open any text editor on your PC. We would recommend you to use Notepad++
Copy the following code.

int main()
    printf("Hello World!");
    return 0;

Save the file as helloworld.c in the following directory
C:>cygwin64>home>user(your PC name), that is inside cygwin64 folder in Local Disk C.

Open Cygwin terminal from your desktop.

To compile any program in Cygwin, simply typ

>> g++ -std=c++1y (filename with extension)

In this case type

>> g++ -std=c++1y helloworld.c

After compiling run the following command to execute the program

>> ./a.exe

And now you have successfully installed a GCC Compiler on your Windows OS!
Thank you for reading.

Thank you for reading

Tweet your queries and feedback to @PsychoCodes or leave a message on our Facebook page. You can also comment your questions below.

Also, don't forget to subscribe to our Newsletter.

If you like this article, then please share it and help us grow.

If You Love this article, You Should Consider:

  • Like us on Facebook
  • Follow us on Instagram
  • Follow us on Twitter
  • Subscribe to our Newsletter.
  • Let us know your suggestions and queries in the comments below.

Thank you for your Love and Support

Share your thoughts