top of page

How to Install C Compiler

Updated: Feb 23

C is a general-purpose programming language that was first developed in the early 1970s by Dennis Ritchie at Bell Labs. C was created as an evolution of the B programming language, with the goal of creating a language that was both powerful and easy to use, and that could be used for a wide variety of applications.


One of the key features of C is its portability. C code can be compiled to run on a variety of different hardware platforms, making it a popular choice for systems programming, embedded systems development, and other low-level programming tasks.



There are different installation procedures of the compiler for different operating systems.

Here's how to install a C compiler on some of the most popular operating systems:


Windows

  • Download the installer for the GCC (GNU Compiler Collection) from the MinGW website: https://sourceforge.net/projects/mingw/

  • Run the installer and follow the prompts to install GCC on your computer.

  • After installation is complete, open the Command Prompt or PowerShell and type gcc -v to verify that the compiler is installed and working.

macOS

  • Install Xcode from the Mac App Store.

  • Open the Terminal app and type gcc -v to verify that the compiler is installed and working.

Linux

  • Open the terminal and type sudo apt-get install build-essential to install the GCC compiler on Ubuntu or other Debian-based Linux distributions.

  • Type gcc -v to verify that the compiler is installed and working.

Once you've installed the compiler, you can use a text editor or an integrated development environment (IDE) to write C code. Save your code with a .c extension and then use the compiler to compile your code into an executable file. You can then run the executable file to execute your program.



Here's a simple "Hello, World!" program in C:

#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}

Output


bottom of page