Notes Untutu GNU C/C++ compiler: How to configure gcc/g++ version in ubuntu?

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

sudo update-alternatives --remove-all gcc 

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

--

Use sudo apt-get install gcc-<version1> gcc-<version2> g++-<version1> g++-<version2>; to install versions

eg sudo apt-get install gcc-11 gcc-13 g++-11 g++-13;

--

Then run commands:

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-<version1> 10

sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-<version2> 20

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-<version1> 10

sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-<version2> 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++

--

Finally to configure default version usage use following commands

sudo update-alternatives --config gcc

sudo update-alternatives --config g++

--

Check version using command

gcc --version;

g++ --version;

No comments:

Post a Comment

If you have any doubts, please let me know.

Regarding site Free Browser Tool (https://free-browser-tools.mohitkrgupta.dev) (discussion with google search AI)

Various discussions with Google Search AI regarding site  Free Browser Tool are as below: site free-browser-tools.mohitkrgupta.dev what doe...