Showing posts with label Ubuntu. Show all posts
Showing posts with label Ubuntu. Show all posts

Tuesday, June 2, 2015

How to use multiple versions of GCC/G++

In programming life we may require to install and use multiple versions of the compiler on the same system. For an example, to support for C++11 features gcc/g++ v4.7 or later version is requried and for legacy codes which do not require new features, gcc/g++ v4.6 or below is required.

I'm using Ubuntu 14.04.2 LTS and gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 is the default compiler and the importent thing is it only includes the 'C' compiler, not the 'C++' compiler. As the first step I installed build-essential package using following command,
$ sudo apt-get install build-essential
This gave the expected C++ compiler.

I installed the gcc v4.6 and g++ v4.6 to use as my legacy code compiler using the following command
$ sudo apt-get install gcc-4.6 g++-4.6
Once succesfully installed them, system contains two different versions of C/C++ compilers. Create symbolic links by using update-alternatives keep the record of 2 C/C++ compiler as follows.

$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 10 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 20 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8
From this point on-words, When required to switch compilers between v4.6 and v4.8 following command can be used
$ sudo update-alternatives --config gcc

Friday, October 11, 2013

Install a software in Ubuntu from a PPA

A new software or a new version of a software is released, it is not available in repos of Ubuntu and have to wait until the next release of Ubuntu to try it. But most of the latest software releases are available as PPAs (Personal package archives) in Launchpad and it helps to Ubuntu users to install and try up-to-date versions of software.

A PPA, or Personal Package Archive, is a collection of software not included in Ubuntu by default. It might be an unreleased piece of software which is provided by the community. Therefore user should be aware of the possible risks before adding a PPA.

Here we are going consider the example of “Twisted-dev” Team, which provides PPA of the latest Twisted Development releases. (Twisted is an event-driven networking engine written in Python)

Visit the PPAs overview page in Launchpad and copy the PPA's location which is mentioned under “Adding this PPA to your system” heading. In this example PPA location is ppa:twisted-dev/ppa. You can find Twisted's PPAs overview page in here. Now, run the following command with the PPA's location.
$ sudo add-apt-repository ppa:twisted-dev/ppa
After running above command your sytem will fetch the PPA’s key. This will let your Ubuntu system verify that the packages in the PPA have not been interfered since they were built.

Run the following command to download the latest list of softwares form the each repos that system knows. Including the Twisted PPA.
$ sudo apt-get update
Now all sets to start installing software from the PPA. Use the regular apt-get install or synaptic to download and install it. If the added PPA is for an already installed package, run following command to upgrade it to most recent version.
$ sudo apt-get dist-upgrade
Enjoy the latest version of Twisted or the software have been installed from the PPA!