How to install a specific version of GCC in Kali Linux?

How to install a specific version of GCC in Kali Linux?

GCC 6 is available on kali linux it can be installed as follow :

apt install g++-6 gcc-6

To switch between gcc6 and gcc7

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 1 --slave /usr/bin/g++ g++ /usr/bin/g++-7
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 2 --slave /usr/bin/g++ g++ /usr/bin/g++-6
update-alternatives --config gcc

sample output:

There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-6   2         auto mode
  1            /usr/bin/gcc-6   2         manual mode
  2            /usr/bin/gcc-7   1         manual mode

Press <enter> to keep the current choice[*], or type selection number:

Select your default gcc version.

on 2017-08-05 the gcc-6 version is upgraded from 6.3.0 to 6.4.0 .

Installing xmrig following the build's instructions.

apt-get install git build-essential cmake libuv1-dev libmicrohttpd-dev
git clone https://github.com/xmrig/xmrig.git
cd xmrig
mkdir build
cd build
cmake ..
make

Building a specific gcc version 6.3.0

Download the tarball from the closest mirror : GCC Releases

wget https://ftp.gnu.org/gnu/gcc/gcc-6.3.0/gcc-6.3.0.tar.bz2
tar xvf gcc-6.3.0.tar.gz
cd gcc-6.3.0
apt build-dep gcc
./contrib/download_prerequisites
cd ..
mkdir objdir
cd objdir
$PWD/../gcc-6.3.0/configure --prefix=/usr/bin/gcc-6.3 --enable-languages=c,c++,fortran,go --disable-multilib
make -j 8
make install

Add gcc-6.3 to update-alternatives

Important : The --disable-multilib option is required to configure and build gcc for the current architecture.

GCC WIKI : Installing GCC