The first step in learning any programming language is to have the required software installed in the system. In this tutorial, we will learn how to install C/GCC compiler in Windows.
Although, you may choose any basic text editor such as notepad for writing and editing source code of C, we recommend choosing one of the editors below.
IDEs (Integrated Development Environment) such as Eclipse or Netbeans may be used but if you are a beginner in C programming, prefer using text editors mentioned above.
One of the preferred way to install C/GCC compiler is to use CodeBlocks. Just install it, launch it and start coding to keep things simple. In other words, CodeBlocks is a free C/C++ IDE that comes with the built-in compiler.
Windows users should choose download file which has “mingw” in its name, for example, codeblocks-17.12mingw-setup.exe.
During installation, select Type of Install as “Minimal: Important plugins, important lexers” and make sure “MinGW Compiler Suite” is Checked. This will make sure that GCC compiler is also installed with the IDE.
Once Codeblocks is installed, GCC compiler also gets installed with it. However, if we want to execute C programs from command prompt, we have to add its bin directory to the PATH variable.
Go to installation Directory and copy the path of bin folder, e.g. “C:\Program Files (x86)\CodeBlocks\MinGW\bin”
Go to “Control Panel\System and Security\System”, Click “Advance System Settings” and then “Environment Variables”.
Find the Variable Name “Path” in User or System (if you are administrator) Variables and click on Edit.
If you see a small popup, In “Variable value” box, go to end of text, put a semicolon “;” and paste the path of bin folder i.e. “C:\Program Files (x86)\CodeBlocks\MinGW\bin”
If you see a big popup (usually in windows 10) with the list of Path variables, click on “New” and paste the “bin” folder path.
Press OK on all opened popup windows.
Open cmd and write “gcc” in it, press enter/return key.
If you see “gcc: fatal error: no input files compilation terminated.”, it means that GCC is successfully installed and you can exit the cmd.
In case you get the message “‘gcc’ is not recognized as an internal or external command”, follow steps correctly for installation and configuration of Path variable.
That’s all for installing C/GCC compiler in Windows. We are ready now to explore coding features of C Programming.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
How to download the compiler and set it up on env variables, without downloading built in c compiler in codeblocks?
- Faiq
It has worked sir. Thank you…
- Kumar