banner



How To Install Gcc In Ubuntu 12.04

Adue south a C and C++ developer, it is not uncommon to handle projects that crave different versions of compilers. With advancements in engineering, it'southward probable to notice yourself in a situation where you need a item GCC or G++ compiler version for a specific project.

In this tutorial, we volition show you the method to install multiple versions of GCC and G++ on Ubuntu twenty.04 using the apt install control. Additionally, we volition show you how to switch between various K++ and GCC versions using the update-alternatives and ostend the selected version currently in use.

To ensure you don't miss a chip, nosotros volition divide this tutorial into iii steps, as shown beneath.

  • Install multiple versions of GCC and One thousand++ compilers.
  • Create an culling compiler version list.
  • Switch between multiple GCC and G++ compilers.

Before yous proceed

Our Linux distribution of choice in this tutorial is the recently released Ubuntu 20.04 LTS. Ensure that all packages are up to date using the commands below.

sudo apt update sudo apt upgrade

You will too need elevated privileges by executing commands using the sudo control.

Installing multiple GCC compiler versions on Ubuntu 20.04 LTS

Nosotros volition apply the apt install command. Execute the commands below using the sudo privileges.

sudo apt install build-essential sudo apt -y install gcc-seven gcc-viii
install gcc-7 gcc-8.
installing GCC-7 GCC-8

We will also install GCC 9.0 using the commands below.

sudo add together-apt-repository ppa:jonathonf/gcc-9.0
install GCC -9 repository
install GCC -9 repository
sudo apt-get install gcc-nine
Install GCC-9 on Ubuntu 20.04.
Install GCC-nine on Ubuntu 20.04.

Installing multiple Yard++ compilers on Ubuntu 20.04 LTS

With GCC compilers installed, we can now proceed to install multiple versions of Thou++ compilers.

sudo apt install build-essential  sudo apt -y install g++-7 one thousand++-8 k++-9
Install G++ Compilers
Install Chiliad++ Compilers

Alternatively, you lot tin can install both GCC and Chiliad++ compilers with a unmarried command, as shown below.

sudo apt install build-essential sudo apt -y install gcc-7 g++-7 gcc-eight 1000++-8 gcc-9 chiliad++-ix

Creating a list of GCC and 1000++ alternatives with update-alternatives

Step 1. Launch the Terminal and execute the commands beneath ane by one.

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 7 sudo update-alternatives --install /usr/bin/k++ g++ /usr/bin/g++-7 7 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 8 sudo update-alternatives --install /usr/bin/yard++ g++ /usr/bin/g++-eight 8 sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 9 sudo update-alternatives --install /usr/bin/one thousand++ thou++ /usr/bin/g++-ix ix
Create a List of GCC and G++ aternatives
Create a List of GCC and G++ alternatives

Stride 2. Cheque the GCC and G++ lists available on your system and select the default compiler you wish to use for your development. Let'due south showtime past setting up the GCC compiler.

Launch your Ubuntu Final and execute the command beneath.

sudo update-alternatives --config gcc
Set your default GCC compiler.
Set your default GCC compiler.

Select the GCC compiler you wish to apply by selecting the number under the selections menu. In this tutorial, I chose option two(ii) since I wanted to use GCC-eight as my compiler for my electric current project.

Step 3. Now permit's exercise the same and cull our default G++ compiler. Execute the command below.

sudo update-alternatives --config yard++
Select the Default G++ Compiler
Select the Default G++ Compiler

Here, I am also interested in using 1000++-viii, and therefore, I will select option 2(2), as shown in the image above.

To switch to another GCC or G++ compiler, echo the config process in steps two(2) and three(3) in a higher place. Select a different selection to set some other Compiler version that you wish to apply.

To affirm the changes we have made running the version command on the Concluding for each compiler.

gcc --version g++ --version
Run the G++ and GCC version command.
Run the Grand++ and GCC version control.

From the epitome above, we tin run into that the organisation shows the GCC and M++ compilers that we configured to use as defaults.

That's all about how you can install multiple versions of GCC and G++ compilers and switch between each of them on your Ubuntu machine. If yous have additional data, feel free to share it with our readers in the comment section beneath.

Source: https://www.fosslinux.com/39386/how-to-install-multiple-versions-of-gcc-and-g-on-ubuntu-20-04.htm

Posted by: hobbsspeadervat.blogspot.com

0 Response to "How To Install Gcc In Ubuntu 12.04"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel