M BUZZ CRAZE NEWS
// news

I am using ubuntu 20.04 LTS trying to get from GCC 9.4 to gcc 10 or higher

By Emma Johnson

sudo apt-get install gcc-10 g++-10:

Reading package lists... Done
Building dependency tree
Reading state information... Done
g++-10 is already the newest version (10.3.0-1ubuntu1~20.04).
gcc-10 is already the newest version (10.3.0-1ubuntu1~20.04).
0 upgraded, 0 newly installed, 0 to remove and 31 not upgraded.
<pre>gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion=&apos;Ubuntu 9.4.0-1ubuntu1~20.04&apos; --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-yTrUTS/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04)</pre>

Im new to linux so if there's anything else you need lmk

1

2 Answers

Enter the command gcc-10 instead of gcc to use gcc-10.

Alternatively, you can use the command sudo update-alternatives --config gcc to choose gcc-10 as the default gcc. Similarly, use sudo update-alternatives --config g++ to configure the default g++ version.

2

For any Ubuntu release, the default gcc compiler is selected via a link such as /usr/bin/gcc which links to the actual compiler executable, maybe through other links: /usr/bin/gcc -> gcc-9 -> x86_64-linux-gnu-gcc-9 This is the validated/tested compiler used for the release, and regardless of which compiler version you select for your own use, it is not a good idea to change the system default. Kernel updates may need to rebuild proprietary video modules from vendor supplied binary blobs, and this process is tested with the default compiler. Maybe a later compiler will work, but might not, leaving you booting the latest kernel without the appropriate proprietary video module, causing problems like low resolution (from another video driver) or a even black screen. Multiple compiler versions may be installed, but those installations do not change the /usr/bin/gcc link. You should not manually change that link either, nor should you use update-alternatives to slip a new compiler in.

A user may set up their own environment to run whatever compiler they install via any number of ways. In the case of 20.04 with a default 9.4 compiler and you desire to run a 10 compiler, you may:

  1. Invoke the gcc-10 by name. Use this for managing multiple projects each needing a different compiler. The name may be embedded in project definition files, e.g. in a makefile GCC=gcc-10

  2. Add an alias to your .bashrc file (or equivalent if not running bash). alias gcc="/usr/bin/gcc-10" This way all your projects will get the 10 version of the compiler with the invocation of gcc.

  3. Add a link named gcc in your home directory's bin to the selected compiler version. This assumes your $HOME/bin is earlier in your PATH than /usr/bin or /bin. Again, this will let gcc invoke your selected compiler everywhere.

4)project specific config files may set up aliases or links in project bin directories for controlling what gcc invokes.

Select the mechanism which best suits your needs.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy