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

POSTED BY Mohd ShibliCATEGORY programming

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.
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 ?

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 directoryC:>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 typeg++ -std=c++1y (filename with extension)
In this case typeg++ -std=c++1y helloworld.c

After compiling run the following command to execute the program

And now you have successfully installed a GCC Compiler on your Windows OS!
Thank you for reading.
Tweet your queries and feedback to @PsychoCodes ,leave a message on our Facebook page or comment below. Also, don't forget to subscribe to our Newsletter at the top of this page.If you like the article then please share it and help us grow.

Понравилась статья? Поделиться с друзьями:
Добавить комментарий