Configuring C, C++ Development Environment in Linux

In this tutorial, we are going to set up C and C++ development environment in Operating Systems like Arch Linux, UbuntuCentOS/ Red Hat, Fedora and OpenSUSE.

It includes following components:

For a successful installation type/ paste following commands in your favourite terminal application.

1. Perform Full System Update.

Arch Linux:

sudo pacman -Syu

Ubuntu:

sudo apt update

sudo apt upgrade

CentOS/ Red Hat:

sudo yum update

Fedora 22 and later:

sudo dnf update

OpenSUSE:

sudo zypper ref

sudo zypper up

2. Install Compiler.

Arch Linux:

Depending upon which kernel you use (Stable/ Hardened/ LTS/ ZEN) this step may vary. I am using stable kernel for this tutorial.

sudo pacman -S base-devel

Ubuntu:

sudo apt install build-essential

CentOS/ Red Hat 7:

sudo yum group install ‘Development Tools’

Fedora 22 and later:

sudo dnf group install ‘Development Tools’

OpenSUSE:

sudo zypper in -t pattern devel_C_C++

3. Install IDE (Integrated Development Environment)

Our C, C++ programs can be compiled using gcc/ g++ via command line, or by using an IDE. The least complicated way is to use an IDE. In this tutorial, I am demonstrating installation of Code::Blocks, Geany and Eclipse. You need to install any one IDE to get work done.

I run Geany on my daily driver, as it is a lightweight, un-complicated IDE and gets my work done in most situations. Code::Blocks is a feature-rich IDE, and Eclipse is the most feature-rich and customisable among three.

Arch Linux:

sudo pacman -S geany

sudo pacman -S codeblocks

sudo pacman -S eclipse-cpp

Ubuntu:

sudo apt install geany

sudo apt install codeblocks

sudo apt install eclipse

CentOS/ Red Hat 7/ Fedora:

sudo yum install geany

sudo yum install codeblocks

Download Eclipse binaries from here.

Change directory to downloads:

cd ~/Downloads

Extract binaries to /opt

tar -zxvf eclipse-inst-linux64.tar.gz

cp eclipse /opt

Create a symbolic link to /usr/bin directory

ln -s /opt/eclipse/eclipse /usr/bin/eclipse

OpenSUSE:

sudo zypper in geany

As Code::Blocks isn’t available in OpenSUSE repositories, we need to manually add Code::Blocks repository in our system, or install it using one-click install. The easiest way is to use one-click-install.

OpenSUSE 42.3

Click here to install via one-click install.

OpenSUSE 42.2

Click here to install via one-click install.

Source.

As Eclipse too isn’t available in OpenSUSE repositories, we will be using one-click installation.

OpenSUSE Tumbleweed

Click here to install via one-click install.

OpenSUSE 42.3

Click here to install via one-click install.

OpenSUSE 42.2

Click here to install via one-click install.

Source.

Our C, C++ code can be compiled without using an IDE too. i.e. by compiling code from the command line using gcc/ g++.

Here’s a way to do it. Open your text editor, paste below code and save it as ‘hello.cpp’.

#include<iostream>
using namespace std;
int main()
{
cout<<“Hello World!”;
return 0;
}

Now open the terminal application, change to the directory where you saved your code. And type/ paste following commands.

g++ hello.cpp -o hello

./hello

I hope this tutorial has helped you install C, C++ Development Environment in your Linux Box. If you have any doubts, find any grammatical errors, or want to request any tutorial, feel free to make use of comments section. Thanks for reading!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s