How to install GCC & G++


How to install GCC & G++

GNU is a compiler or writes the word to say a combination of compilers. It compiles mainly C, C++, Fortran, Ada, Go, and D.Its freely available.


Installing in Ubuntu 18.04

The following command is used to install GCC in ubuntu. You need to open the terminal first. then type or this command is also used to check gcc install or not.


  $ sudo apt-get update
  $ sudo apt install gcc

If GCC is already installed in your system then the following message will appear 

Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:7.4.0-1ubuntu2.3).
The following packages were automatically installed and are no longer required:
  blt libcgns3.3 libgles2-mesa-dev libjs-jquery-ui libjs-sphinxdoc libllvm6.0
  libqt4-help libqt5concurrent5 libqt5designercomponents5 libqt5opengl5
  libqt5opengl5-dev libqt5positioning5 libqt5quickwidgets5 libqt5sensors5
  libqt5webchannel5 libqt5webkit5 libtcl8.5 libvtk6.3-qt paraview-doc
  python-matplotlib-data qt5-assistant qt5-qmake qt5-qmake-bin qtbase5-dev
  qtbase5-dev-tools qttools5-dev qttools5-dev-tools tcl8.5 tk8.6-blt2.5
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 70 not upgraded.

Install build-essential

We can also install it in another way, it is also a part of the build-essential  package. this package will also help to update the g++ compiler. You can also you the following command to make sure everything is working 

 $ sudo apt install build-essential 
If build-essential is installed and already latest version is your system then you will see this message
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.4ubuntu1).
The following packages were automatically installed and are no longer required:
  blt libcgns3.3 libgles2-mesa-dev libjs-jquery-ui libjs-sphinxdoc libllvm6.0
  libqt4-help libqt5concurrent5 libqt5designercomponents5 libqt5opengl5
  libqt5opengl5-dev libqt5positioning5 libqt5quickwidgets5 libqt5sensors5
  libqt5webchannel5 libqt5webkit5 libtcl8.5 libvtk6.3-qt paraview-doc
  python-matplotlib-data qt5-assistant qt5-qmake qt5-qmake-bin qtbase5-dev
  qtbase5-dev-tools qttools5-dev qttools5-dev-tools tcl8.5 tk8.6-blt2.5
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 70 not upgraded.

Check GCC version

Sometimes small things make a really big change. Just think if you write your whole c++ program and somewhere you miss ";".This is also the same every time when c++ update they change something. The code that writes in the old version may have some problem in the new update.BUT this is a very rear case. Before running code and you want to use new features checking updates of the compiler is good practices always. The following code help to see which version is installed in your system.
 $ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 $ g++ --version
g++ (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

Please comment if you have any suggestion and share to support us

😀 😄 😍 💗

0 Comments

Oldest