This article will demonstrate how you can install C programming language in your computer.
What is C programming language ?
C is a general purpose programming language. By ‘general purpose’, it means that it can be used to create programs / software of a wide variety. Although C is a very old programming language, it is still one of the most powerful and used tools. Specially for building very fundamental software, like operating systems, kernels, databases etc.
Although C uses a compiler, it is still not completely considered a high level language. As it can be used to create very basic kind of software, like kernels and drivers, and can be used at the same level where assemble languages (low level language) run.
You can read more about high level and low level language here.
Why C is great
- As I have already mentioned, C is a general purpose language and has a great variety of use cases.
- It sits very close to the computer hardware, hence can be useful to understand the fundamental theory of computers.
- It is relatively faster than most of the programming languages out there as it has fewer utilities attached to it which might help to make it easier to work with. For example – Garbage collection, and dynamic typing. These are some facilities provided in languages like python, java etc. so that they are easier to use. So basically C might be a little bit harder to learn.
- It has derived many other languages like Java, Python, C++, C#, etc.
Installing C in your computer might be a little bit more complicated than installing other languages like python. Where in python all you needed to do was to install the python interpreter from python.org, to work with C, first you need to download a compiler, but the thing is, there is no ONE OFFICIAL C compiler, there are many ! With each having different setup process.
Here is the list of some of the compilers of C
- CCS C Compiler
- Turbo C
- Minimalist GNU for Windows (MinGW)
- Portable C Compiler
- Clang C++
- Embarcadero C++
- Edison Design Group C++
- Green Hills C++
- HP C++ for Unix
We will be using the MinGW compiler, which is in fact derived from GNU GCC compiler itself.
There are many ways to install C compiler MinGW. But most people prefer to download it from sourceforge.net
It will give you a .zip file. Extract it and do the installation. Install it at the destination you want.
You might also use MYSYS2 (instructions are given in this page) instead to do so. In my case, I was having some issues with the MinGW file I downloaded from sourceforge. I don’t know why but it didn’t have everything that is supposed to be there. So I uses MYSYS2 to install MinGW instead and it worked.
Setting environment path variable
If you have worked with python. You might remember that after installing the python interpreter, you are able to run python commands using ‘python’ keyword in the command prompt . This keyword is called an environment variable. In the case of our C compiler, we need to set this manually so that it can be used from any directory.
To do that, first, go to the folder where you installed the mingw64 file. There you might find a bin folder. And inside that, try to find the gcc.exe file. It is at different places when you download mingw from different source.
Best way to find yours is to search for ‘gcc.exe’ in the windows search bar (or somewhere).
Copy the address where you find this .exe file.
Right click on ‘this pc’ in the file manager and select properties. That would take you to the settings. There click on ‘advanced system settings’.
This will give you a ‘system properties’ popup. There go to ‘Environment Variables’.
In the ‘user variable YOUR USERNAME‘ portion, you will notice a ‘path’ option. Select it and click on edit.
Notice how there is a python environment variable there.
Now go to new and paste the address of the gcc.exe file and save changes.
Congratulations, you can now use gcc command to compile any C code from anywhere from your computer.