Upgrade gcc c++ compiler

In order to compile a software package from a compilation failure, I am told to upgrade the gcc-c++ compiler from default version 7 to version 10 as there are needed updated compiler modules. I have installed version gcc-c++10 from software repos.
I notice there are link files:

/usr/bin/c++ and
/usr/bin/g++

they point to the use of c++7. I believe these, these links need to be modified to point to gcc-c++10 that was just installed. I don’t believe two versions can coexist

  1. Could you point me to specific instructions for changing these links. I have seen conflicting recommendations of how to do this. Most say delete link then reinstall. Some say you can mod the link.

  2. What does the g++ link refer to?

  3. Are there any additional changes necessary to move to gcc-c++10 and avoid any conflicts with v7?

  4. Am I hurting anything elsewhere by changing to gcc-c++10?

thanks, tom kosvic

Hi
Normally done via update-alternatives, however in your case better to just export the CC and CXX flags at configure/build time (check the configure or makefile to see what is used).

I think Tumbleweed is using gcc10, and has other versions available. It might be using “/etc/alternatives” to select which is the default.

In any case, typically one builds software use “make” and you define the compile in a line in the “Makefile”. That is to say, the “Makefile” sets the default to be used for that build.

SOLVED:

thanks for advice. Rather than change system wide c++ compiler just install the others and make specific calls to them in the configure/make files. Makes good sense.

tom kosvic

If you’re compiling,
then you can modify your make files to point to a specific compiler.

But there are other scenarios when that might not be possible.
Unless something has changed, when you install an alternative gcc on an openSUSE, it installs side by side but does not come with an easy way to reconfigure the default system version.

Awhile back I wrote a Wiki article how to create an Alternatives to easily switch between different installed gcc

https://en.opensuse.org/User:Tsu2/gcc_update-alternatives

TSU

If you’re using CMake, simply use the “CMAKE_<LANG>_COMPILER” variable to define which compiler shall be used – <https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html&gt;.