Score:0

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

cn flag

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

Nmath avatar
ng flag
`31 not upgraded`. Your system is not up-to-date. Always run `sudo apt update` before any other command in `apt` and you should perform updates with `sudo apt upgrade` before attempting to install new software. Also, when giving us the output of commands, be sure to provide the exact command and the entire output. Don't give us bits and pieces because you can leave out essential diagnostic info.
Score:1
us flag

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.

cc flag
Search this site for "update broke my computer" for some of the consequences of replacing the default gcc version. Change the user's gcc default, via some other mechanism, like an alias, or a gcc link in $HOME/bin to avoid an update failing to recompile a video driver.
us flag
@ubfan1 Why would a update use gcc to compile something? Feel free to edit my answer.
Philipp Ludwig avatar
tr flag
@ArchismanPanigrahi He is probably using the NVIDIA proprietary driver, which compiles a module during the installation process.
fr flag
What if `sudo update-alternatives --config gcc` just returns `update-alternatives: error: no alternatives for gcc`? I have both `gcc-11` and `gcc-12` installed. `/usr/bin/gcc` is linked to `gcc-11`. Observed on Ubuntu 22.04.1, fully updated.
us flag
@AndrásAszódi I don't know about this. Can you ask a new question (and clearly mention the issue - why this answer does not work)?
fr flag
@ArchismanPanigrahi Thank you for your suggestion. I am still investigating the issue. I installed the compilers into a "minimal server installation", it could be that I simply forgot something... I suspect that if I start with `sudo apt-get install gcc` instead of `...install gcc-11` (i.e. without asking for a specific version) then it may work. But in order to test that I need to get back to a pristine state... we'll see.
Score:0
cc flag

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.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.