Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Refer "How to install multiple versions of GCC" here in the GNU GCC FAQ.

There's also a white paper here.

you can also use update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use. This is done with the following:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60 --slave /usr/bin/g++ g++/usr/bin/g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 40 --slave /usr/bin/g++ g++ /usr/bin/g++-6.2    
sudo update-alternatives --config gcc

From this point forward, the only thing required when switching compilers is this command:

sudo update-alternatives --config gcc

Regards.,

Refer "How to install multiple versions of GCC" here in the GNU GCC FAQ.

There's also a white paper here.

you can also use update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use. This is done with the following:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++/usr/bin/g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 /usr/bin/gcc-6.2 40 --slave /usr/bin/g++ g++ /usr/bin/g++-6.2    
sudo update-alternatives --config gcc

From this point forward, the only thing required when switching compilers is this command:

sudo update-alternatives --config gcc

Regards.,

Refer "How to install multiple versions of GCC" here in the GNU GCC FAQ.

There's also a white paper here.

you can also use update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use. This is done with the following:

FOR EXAMPLE 4.3 an 4.4 please change as your need :

First erased the current update-alternatives setup for gcc and g++:

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++

Install Alternatives

Symbolic links cc and c++ are installed by default. We will install symbol links for gcc and g++, then link cc and c++ to gcc and g++ respectively.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++/usr/bin/g++-4.9
/usr/bin/gcc-4.3 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6.2 40 --slave /usr/bin/gcc-4.4 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-6.2    
/usr/bin/g++-4.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 20

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++

Configure Alternatives

The last step is configuring the default commands for gcc, g++. It's easy to switch between 4.3 and 4.4 interactively:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

From this point forward, the only thing required when switching compilers is this command:

sudo update-alternatives --config gcc

Regards.,

Refer "How to install multiple versions of GCC" here in the GNU GCC FAQ.

There's also a white paper here.

you can also use update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use. This is done with the following:

FOR EXAMPLE 4.3 an 4.4 please change as your need :

First erased the current update-alternatives setup for gcc and g++:

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++

Install Alternatives

Symbolic links cc and c++ are installed by default. We will install symbol links for gcc and g++, then link cc and c++ to gcc and g++ respectively.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.3 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 20

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++

Configure Alternatives

The last step is configuring the default commands for gcc, g++. It's easy to switch between 4.3 and 4.4 interactively:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++

or :

If you just want to build things with a different version of gcc, that's easy enough, even with makescripts. For example, you can pass in the version of gcc in the CC environment variable:

CC="gcc-4.5" ./configure
CC="gcc-4.5" make

Regards.,

Refer "How to install multiple versions of GCC" here in the GNU GCC FAQ.

There's also a white paper here.

you can also use update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use. This is done with the following:

FOR EXAMPLE 4.3 an 4.4 please change as your need :

First erased the current update-alternatives setup for gcc and g++:

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++
g++ or gcc-++

Install Alternatives

Symbolic links cc and c++ are installed by default. We will install symbol links for gcc and g++, then link cc and c++ to gcc and g++ respectively.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.3 10
10 (or gcc-++)
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 20
20 (or gcc++)

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
30 or (gcc-++)
sudo update-alternatives --set c++ /usr/bin/g++
/usr/bin/g++ or (gcc-++)

Configure Alternatives

The last step is configuring the default commands for gcc, g++. It's easy to switch between 4.3 and 4.4 interactively:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++
g++ or (gcc-++)

or :

If you just want to build things with a different version of gcc, that's easy enough, even with makescripts. For example, you can pass in the version of gcc in the CC environment variable:

CC="gcc-4.5" ./configure
CC="gcc-4.5" make

Regards.,

Refer "How to install multiple versions of GCC" here in the GNU GCC FAQ.

There's also a white paper here.

you can also use update-alternatives to know that you have 2 C/C++ compilers, create a record for each one, and then configure which one you want to use. This is done with the following:

FOR EXAMPLE 4.3 an 4.4 please change as your need :

First erased the current update-alternatives setup for gcc and g++:

sudo update-alternatives --remove-all gcc 
sudo update-alternatives --remove-all g++ or gcc-++

Install Alternatives

Symbolic links cc and c++ are installed by default. We will install symbol links for gcc and g++, then link cc and c++ to gcc and g++ respectively.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.3 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.4 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.3 10 (or gcc-++)
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.4 20 (or gcc++)

sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set cc /usr/bin/gcc

sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30 or (gcc-++)
sudo update-alternatives --set c++ /usr/bin/g++ or (gcc-++)
(or gcc-++)

Configure Alternatives

The last step is configuring the default commands for gcc, g++. It's easy to switch between 4.3 and 4.4 interactively:

sudo update-alternatives --config gcc
sudo update-alternatives --config g++ or (gcc-++)

or :

If you just want to build things with a different version of gcc, that's easy enough, even with makescripts. For example, you can pass in the version of gcc in the CC environment variable:

CC="gcc-4.5" ./configure
CC="gcc-4.5" make

Regards.,