C Compiler

C compiler & its installation processes.

* Before learning the C language compiler installation process, you must clear a basic concept about assembler, compiler & interpreter.

An assembler, compiler, and interpreter are all tools used in the field of computer programming and software development to facilitate the process of converting high-level programming code into machine code or executing it. Each of these tools serves a different purpose and operates in a distinct way.

Installation of C Compiler

To install a C compiler on your computer, you will need to choose a specific C compiler based on your operating system. The two most commonly used C compilers are GCC (GNU Compiler Collection) and Code::Blocks. Here are instructions for installing these compilers on different operating systems:

1. Installing GCC:

On Linux:

Most Linux distributions come with GCC pre-installed. To check if it's installed, open a terminal and run the following command:

bash Copy Code
gcc --version

If GCC is not installed, you can install it using your package manager. For example, on Ubuntu or Debian-based systems, you can use:

bash Copy Code
sudo apt-get update
sudo apt-get install gcc

On macOS:

macOS doesn't come with GCC pre-installed, but you can install it using the Homebrew package manager. First, install Homebrew if you haven't already by following the instructions at https://brew.sh/. Then, run the following command to install GCC:

bash Copy Code
brew install gcc

On Windows:

You can install GCC on Windows using the Windows Subsystem for Linux (WSL). First, install WSL following the Microsoft documentation (https://docs.microsoft.com/en-us/windows/wsl/install). After setting up WSL, you can use the Linux package manager to install GCC, just like you would on a Linux system.

Still, You can also try this one-line command (In administrator mode) for a quick installation process:

PowerShell Copy Code
wsl --install -d ubuntu

2. Code::Blocks:

Code::Blocks is an open-source & cross-platform integrated development environment (IDE) used for programming in various programming languages. It provides a user-friendly interface for writing, compiling, and debugging code. Code::Blocks is particularly popular among C and C++ developers, but it supports multiple programming languages and can be extended with plugins to support additional languages and functionality.

Compile the C File

To compile 'hello.c' using GCC, run the following command:

bash Copy Code
gcc hello.c -o hello

That's it! You've successfully compiled and run a C program from the command line. Remember to replace 'hello.c' and hello with your C source file's name and the desired output executable name.

Representations of Program

Source program, object program, and executable program are three stages or representations of a computer program during the software development process. Each serves a specific purpose and has distinct characteristics. Here's an explanation of the differences between them:

Source Program:

The set of instruction written in any one of the programming languages is called source program.

Object Program:

The translated or binary form of a source program is called an object program.

Executable Program:

A program generated from object program by linking the input/output devices in order to execute th instructions given in a source program is called an executable program.

What's Next?

We actively create content for our YouTube channel and consistently upload or share knowledge on the web platform.