This is not recommended but you can install version 11.3 by downloading gcc-11 (version 11.3) from here. And downloading the dependencies gcc-11-base and libgcc-11-dev.
Then, run sudo apt install /path/to/file where /path/to/file is the path to the actual downloaded file. If it can't find the file, you may need to put it in double quotes like "/path/to/file".
You will need to install the gcc-11-base package first, then libgcc-11-dev and finally, gcc-11.
For example, if it's downloaded to your Downloads directory:
sudo apt install $HOME/Downloads/gcc-11-base_11.3.0-6ubuntu1_amd64.deb
and
sudo apt install $HOME/Downloads/libgcc-11-dev_11.3.0-6ubuntu1_amd64.deb
and
sudo apt install $HOME/Downloads/gcc-11_11.3.0-6ubuntu1_amd64.deb
I'm pretty sure gcc only requires gcc-11 >11.2 so this should downgrade your version of gcc and when you're done compiling or whatever you need it for, simply run:
sudo apt update
sudo apt install --reinstall gcc-11 gcc-11-base libgcc-11-dev
to upgrade back to the current version of gcc-11 (11.4).
Granted, the installation isn't guaranteed to work, could be insecure or lacking security updates. Also, you may run into dependency issues. If that's the case, you'd have to tread carefully or install each dependency one by one but always pay attention to what, if any, packages would need to uninstall when installing weird versions because you don't want to inadvertently uninstall a bunch of stuff you want or need.
EDIT: you will need to install dependencies (included above) but you can run the following commands to do it more quickly.
Run the following commands to create a working directory and download the packages:
cd
mkdir GCC11.3
cd GCC11.3
wget 'http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-11/gcc-11-base_11.3.0-6ubuntu1_amd64.deb'
wget 'http://mirrors.kernel.org/ubuntu/pool/main/g/gcc-11/libgcc-11-dev_11.3.0-6ubuntu1_amd64.deb'
wget 'http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-11/gcc-11_11.3.0-6ubuntu1_amd64.deb'
Now, install the packages. Again, however, remember to pay attention to what, if any packages will be uninstalled when you install these weird versions. Review the list before you select Y to accept the changes!:
sudo apt install ./gcc*.deb
And again, when you're done compiling or whatever you need gcc 11.3 for, simply run:
sudo apt install --reinstall gcc-11 gcc-11-base libgcc-dev
to upgrade back to gcc 11.4.
Answer from mchid on askubuntu.comWhen gcc-11 will appear in Ubuntu repositories? - Stack Overflow
How important are gcc versions?
gcc version mismatch warning, but the versions are the same...
network programming - How can I replace gcc with g++-11 for C++20 when running cmake - Stack Overflow
sudo apt install build-essential manpages-dev software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update && sudo apt install gcc-11 g++-11
Then use update-alternatives to set default gcc...
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 --slave /usr/bin/gcov gcov /usr/bin/gcov-9 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-9 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-9 --slave /usr/bin/cpp cpp /usr/bin/cpp-9 && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 110 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11 --slave /usr/bin/gcc-ar gcc-ar /usr/bin/gcc-ar-11 --slave /usr/bin/gcc-ranlib gcc-ranlib /usr/bin/gcc-ranlib-11 --slave /usr/bin/cpp cpp /usr/bin/cpp-11;
To sample check settings to see which gcc is default you can run the following, if they show correct resuslts then the rest are fine...
gcc --version;g++ --version;gcov --version;
To reconfigure to any previous gcc version...
sudo update-alternatives --config gcc
You can do this on any version of ubuntu,... enjoy!
Here are my 6 different gcc's living side by side with the default being gcc-11:
$ sudo update-alternatives --config gcc
There are 6 choices for the alternative gcc (providing /usr/bin/gcc).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gcc-11 1010 auto mode
1 /usr/bin/gcc-10 1000 manual mode
2 /usr/bin/gcc-11 1010 manual mode
3 /usr/bin/gcc-5 40 manual mode
4 /usr/bin/gcc-7 700 manual mode
5 /usr/bin/gcc-8 800 manual mode
6 /usr/bin/gcc-9 900 manual mode
Press <enter> to keep the current choice[*], or type selection number:
On Ubuntu 20.04, I followed the instructions here:
- https://packages.ubuntu.com/hirsute/amd64/gcc-11-multilib/download
Which is to:
Update the listed mirrors by adding a line to your /etc/apt/sources.list like this:
sudo add-apt-repository 'deb http://mirrors.kernel.org/ubuntu hirsute main universe'Choose a mirror based on your location from the list. I chose the kernel mirror as I am in North America.
sudo apt-get updatesudo apt-get install gcc-11
After that which gcc-11 should produce a path to gcc-11. On my machine it was:
which gcc-11
produces: /usr/bin/gcc-11
I have started getting unto assembly and optimising code and I was wandering how important if at all is it to upgrade the computer I am using.
Currently I am on gcc 11.4 which feels fairly old at this point when I am looking at what's out there.
Are the differences between versions thst big or is it generally fairly unimportant
Hello, I encountered a weird warning, as stated in the title, the warning is:
... warning: the compiler differs from the one used to build the kernel The kernel was built by: x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 You are using: gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 ...
Other info:
$ cat /proc/version Linux version 6.2.0-39-generic (buildd@lcy02-amd64-045) (x86_64-linux-gnu-gcc-11 (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #40~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Nov 16 10:53:04 UTC 2 $ gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa OFFLOAD_TARGET_DEFAULT=1 Target: x86_64-linux-gnu ... gcc version 11.4.0 (Ubuntu 11.4.0-1ubuntu1~22.04)
Can anyone help? Thanks!