Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How to install latest gcc on Ubuntu LTS (12.04, 14.04, 16.04)
These commands are based on a askubuntu answer http://askubuntu.com/a/581497
To install gcc-6 (gcc-6.1.1), I had to do more stuff as shown below.
USE THOSE COMMANDS AT YOUR OWN RISK. I SHALL NOT BE RESPONSIBLE FOR ANYTHING.
ABSOLUTELY NO WARRANTY.
If you are still reading let's carry on with the code.
sudo apt-get update && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update && \
sudo apt-get install gcc-snapshot -y && \
sudo apt-get update && \
sudo apt-get install gcc-6 g++-6 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
sudo apt-get install gcc-4.8 g++-4.8 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8;
When completed, you must change to the gcc you want to work with by default. Type in your terminal:
sudo update-alternatives --config gcc
To verify if it worked. Just type in your terminal
gcc -v
If everything went fine you should see gcc 6.1.1 by the time I am writing this gist
Happy coding!
See my blog post at https://www.application2000.com
@abst0603
Copy link

abst0603 commented Nov 27, 2018

Thanks. It works perfectly!

@ZeliangSu
Copy link

ZeliangSu commented Jan 2, 2019

Thank you a lot but I'm getting confused if the g++ was well install, because I got error during the installation

update-alternatives: error: no alternatives for g++
I was installing main:gcc-6 g++6 then:gcc-7 g++-7

Then when I did g++ -v, I got:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 6.5.0-2ubuntu116.04' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --with-as=/usr/bin/x86_64-linux-gnu-as --with-ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-6 --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 --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --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-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.5.0 20181026 (Ubuntu 6.5.0-2ubuntu1
16.04)

@zimenglan-sysu-512
Copy link

zimenglan-sysu-512 commented Apr 6, 2019

thanks @peterhanneman
it solves my problem.

@SamehHassanein
Copy link

SamehHassanein commented May 4, 2019

Not working on UBUNTU 12.04, below the errors

sameh@sameh-HP-EliteBook-2570p:~$ sudo apt-get update && \

sudo apt-get install build-essential software-properties-common -y &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y &&
sudo apt-get update &&
sudo apt-get install gcc-snapshot -y &&
sudo apt-get update &&
sudo apt-get install gcc-6 g++-6 -y &&
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 &&
sudo apt-get install gcc-4.8 g++-4.8 -y &&
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8;
[sudo] password for sameh:
Hit http://security.ubuntu.com precise-security Release.gpg
Hit http://at.archive.ubuntu.com precise Release.gpg
Hit http://at.archive.ubuntu.com precise-updates Release.gpg
Hit http://at.archive.ubuntu.com precise-backports Release.gpg
Hit http://archive.canonical.com precise Release.gpg
Hit http://extras.ubuntu.com precise Release.gpg
Hit http://at.archive.ubuntu.com precise Release
Hit http://at.archive.ubuntu.com precise-updates Release
Hit http://ppa.launchpad.net precise Release.gpg
Hit http://security.ubuntu.com precise-security Release
Hit http://at.archive.ubuntu.com precise-backports Release
Hit http://archive.canonical.com precise Release
Hit http://extras.ubuntu.com precise Release
Hit http://at.archive.ubuntu.com precise/main Sources
Hit http://at.archive.ubuntu.com precise/restricted Sources
Hit http://at.archive.ubuntu.com precise/universe Sources
Hit http://at.archive.ubuntu.com precise/multiverse Sources
Hit http://at.archive.ubuntu.com precise/main i386 Packages
Hit http://at.archive.ubuntu.com precise/restricted i386 Packages
Hit http://at.archive.ubuntu.com precise/universe i386 Packages
Hit http://at.archive.ubuntu.com precise/multiverse i386 Packages
Hit http://at.archive.ubuntu.com precise/main TranslationIndex
Hit http://at.archive.ubuntu.com precise/multiverse TranslationIndex
Hit http://security.ubuntu.com precise-security/main Sources
Hit http://at.archive.ubuntu.com precise/restricted TranslationIndex
Hit http://at.archive.ubuntu.com precise/universe TranslationIndex
Hit http://at.archive.ubuntu.com precise-updates/main Sources
Get:1 http://dl.google.com stable Release.gpg [819 B]
Hit http://at.archive.ubuntu.com precise-updates/restricted Sources
Hit http://at.archive.ubuntu.com precise-updates/universe Sources
Hit http://archive.canonical.com precise/partner i386 Packages
Hit http://extras.ubuntu.com precise/main Sources
Hit http://at.archive.ubuntu.com precise-updates/multiverse Sources
Hit http://at.archive.ubuntu.com precise-updates/main i386 Packages
Hit http://at.archive.ubuntu.com precise-updates/restricted i386 Packages
Hit http://at.archive.ubuntu.com precise-updates/universe i386 Packages
Hit http://at.archive.ubuntu.com precise-updates/multiverse i386 Packages
Hit http://at.archive.ubuntu.com precise-updates/main TranslationIndex
Hit http://security.ubuntu.com precise-security/restricted Sources
Hit http://security.ubuntu.com precise-security/universe Sources
Hit http://security.ubuntu.com precise-security/multiverse Sources
Hit http://security.ubuntu.com precise-security/main i386 Packages
Hit http://security.ubuntu.com precise-security/restricted i386 Packages
Hit http://ppa.launchpad.net precise Release
Hit http://at.archive.ubuntu.com precise-updates/multiverse TranslationIndex
Hit http://at.archive.ubuntu.com precise-updates/restricted TranslationIndex
Hit http://at.archive.ubuntu.com precise-updates/universe TranslationIndex
Hit http://at.archive.ubuntu.com precise-backports/main Sources
Hit http://security.ubuntu.com precise-security/universe i386 Packages
Hit http://security.ubuntu.com precise-security/multiverse i386 Packages
Hit http://security.ubuntu.com precise-security/main TranslationIndex
Hit http://security.ubuntu.com precise-security/multiverse TranslationIndex
Hit http://security.ubuntu.com precise-security/restricted TranslationIndex
Hit http://archive.canonical.com precise/partner TranslationIndex
Hit http://extras.ubuntu.com precise/main i386 Packages
Ign http://extras.ubuntu.com precise/main TranslationIndex
Hit http://at.archive.ubuntu.com precise-backports/restricted Sources
Hit http://at.archive.ubuntu.com precise-backports/universe Sources
Hit http://at.archive.ubuntu.com precise-backports/multiverse Sources
Hit http://at.archive.ubuntu.com precise-backports/main i386 Packages
Hit http://at.archive.ubuntu.com precise-backports/restricted i386 Packages
Hit http://at.archive.ubuntu.com precise-backports/universe i386 Packages
Hit http://at.archive.ubuntu.com precise-backports/multiverse i386 Packages
Hit http://at.archive.ubuntu.com precise-backports/main TranslationIndex
Hit http://at.archive.ubuntu.com precise-backports/multiverse TranslationIndex
Hit http://at.archive.ubuntu.com precise-backports/restricted TranslationIndex
Hit http://archive.canonical.com precise/partner Translation-en
Hit http://security.ubuntu.com precise-security/universe TranslationIndex
Hit http://at.archive.ubuntu.com precise-backports/universe TranslationIndex
Hit http://at.archive.ubuntu.com precise/main Translation-en
Hit http://at.archive.ubuntu.com precise/multiverse Translation-en
Hit http://at.archive.ubuntu.com precise/restricted Translation-en
Hit http://at.archive.ubuntu.com precise/universe Translation-en
Hit http://at.archive.ubuntu.com precise-updates/main Translation-en
Hit http://at.archive.ubuntu.com precise-updates/multiverse Translation-en
Hit http://at.archive.ubuntu.com precise-updates/restricted Translation-en
Hit http://at.archive.ubuntu.com precise-updates/universe Translation-en
Hit http://at.archive.ubuntu.com precise-backports/main Translation-en
Hit http://security.ubuntu.com precise-security/main Translation-en
Hit http://security.ubuntu.com precise-security/multiverse Translation-en
Hit http://at.archive.ubuntu.com precise-backports/multiverse Translation-en
Hit http://at.archive.ubuntu.com precise-backports/restricted Translation-en
Hit http://at.archive.ubuntu.com precise-backports/universe Translation-en
Hit http://ppa.launchpad.net precise/main Sources
Hit http://security.ubuntu.com precise-security/restricted Translation-en
Hit http://security.ubuntu.com precise-security/universe Translation-en
Hit http://dl.google.com stable Release
Ign http://dl.google.com stable Release
Hit http://ppa.launchpad.net precise/main i386 Packages
Ign http://extras.ubuntu.com precise/main Translation-en_US
Ign http://extras.ubuntu.com precise/main Translation-en
Hit http://ppa.launchpad.net precise/main TranslationIndex
Ign http://dl.google.com stable/main TranslationIndex
Hit http://ppa.launchpad.net precise/main Translation-en
Err http://dl.google.com stable/main i386 Packages
404 Not Found [IP: 2a00:1450:4016:80c::200e 80]
Ign http://dl.google.com stable/main Translation-en_US
Ign http://dl.google.com stable/main Translation-en
Fetched 819 B in 3s (228 B/s)
W: GPG error: http://dl.google.com stable Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 6494C6D6997C215E
W: Failed to fetch http://dl.google.com/linux/chrome/deb/dists/stable/main/binary-i386/Packages 404 Not Found [IP: 2a00:1450:4016:80c::200e 80]

@supmit13
Copy link

supmit13 commented May 20, 2019

Worked like a charm for me. Thanks a ton.

@ivanmara555
Copy link

ivanmara555 commented May 23, 2019

@Newk77
Copy link

Newk77 commented Jun 15, 2019

Thank you!!

@tgnurulhuda
Copy link

tgnurulhuda commented Jun 26, 2019

Thanks @peterhanneman

GCC 7.1 on Ubuntu 14.04 & 16.04:

sudo apt-get update -y && \
sudo apt-get upgrade -y && \
sudo apt-get dist-upgrade -y && \
sudo apt-get install build-essential software-properties-common -y && \
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
sudo apt-get update -y && \
sudo apt-get install gcc-7 g++-7 -y && \
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7 && \
sudo update-alternatives --config gcc

@kraj
Copy link

kraj commented Jul 24, 2019

Just in case if someone wants to make multilib ( gcc/g++ -m32 ) work then they also need to install gcc multilib packages

apt-get install gcc-<ver>-multilib lib32stdc++-<ver>-dev lib32gcc-<ver>-dev lib32objc-<ver>-dev

in my case <ver> is 9

@macdi
Copy link

macdi commented Sep 30, 2019

GCC 9.1.0 on Ubuntu 14.04 & 16.04 & 18.04:

sudo apt-get update -y && 
sudo apt-get upgrade -y && 
sudo apt-get dist-upgrade -y && 
sudo apt-get install build-essential software-properties-common -y && 
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && 
sudo apt-get update -y && 
sudo apt-get install gcc-9 g++-9 -y && 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 && 
sudo update-alternatives --config gcc

select gcc-9

Thank you very much worked for me as well on 16.04

@ivanmara555
Copy link

ivanmara555 commented Oct 29, 2019

@sreeragh-ar
Copy link

sreeragh-ar commented Nov 15, 2019

@ivanmara555
Thanks

@Asishinuzuka
Copy link

Asishinuzuka commented Nov 26, 2019

for gcc-3.4 or any older versions of gcc?

@Feez
Copy link

Feez commented Dec 31, 2019

@ivanmara555
Thanks, bud

@MichalMisiaszek
Copy link

MichalMisiaszek commented Jan 30, 2020

Thanks a lot ! It worked like charm in difficult setup.

@liz7124
Copy link

liz7124 commented Feb 12, 2020

@ivanmara555 Thankss, it's work on 16.04

@kundanav
Copy link

kundanav commented Apr 23, 2020

Thanks a lot ! for gcc-4.9?

@ivanmara555
Copy link

ivanmara555 commented May 20, 2020

@tesbayda
Copy link

tesbayda commented May 25, 2020

GCC 10.1.0 on Ubuntu 16.04 & 18.04 & 20.04:

sudo apt-get update -y && 
sudo apt-get upgrade -y && 
sudo apt-get dist-upgrade -y && 
sudo apt-get install build-essential software-properties-common -y && 
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && 
sudo apt-get update -y && 
sudo apt-get install gcc-10 g++-10 -y && 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10 && 
sudo update-alternatives --config gcc

select gcc-10

To ivanmara555's comment using the ppa repository...

As of today May 25th 2020 on Ubuntu 20.04 your list of commands does not install the latest 10.1.0. Instead, it installs the older "10.0.1 20200416 (experimental) (Ubuntu 10-20200416-0ubuntu1)" -- because the older version is the only one there at that PPA site for release "Focal". The other package "10.1.0-2ubuntu1~18.04" is for "Bionic" not "Focal".

On 20.04, run the following commands today (May 25th, 2020) and it shows that none of the packages are 10.1:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt update
sudo apt list -a gcc-10

If you can't find a PPA with "10.1.0", you'll have to build it from source. As a side note, the daily build of the next Ubuntu 20.10 does install 10.1.0.

Today's screenshot of repo https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test/+packages:

2020-05-25__gcc-10_packages_PPA

@Kigerago
Copy link

Kigerago commented Jun 22, 2020

Thx

@JC3
Copy link

JC3 commented Dec 28, 2020

GCC 10.1.0 on Ubuntu 16.04 & 18.04 & 20.04:

sudo apt-get update -y && 
sudo apt-get upgrade -y && 
sudo apt-get dist-upgrade -y && 
sudo apt-get install build-essential software-properties-common -y && 
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && 
sudo apt-get update -y && 
sudo apt-get install gcc-10 g++-10 -y && 
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 60 --slave /usr/bin/g++ g++ /usr/bin/g++-10 && 
sudo update-alternatives --config gcc

select gcc-10

Doesn't seem to work for GCC 10 on 16.04:

$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test
 Toolchain test builds; see https://wiki.ubuntu.com/ToolChain

 More info: https://launchpad.net/~ubuntu-toolchain-r/+archive/ubuntu/test
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpnogzdmz6/secring.gpg' created
gpg: keyring `/tmp/tmpnogzdmz6/pubring.gpg' created
gpg: requesting key BA9EF27F from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpnogzdmz6/trustdb.gpg: trustdb created
gpg: key BA9EF27F: public key "Launchpad Toolchain builds" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

$ sudo apt-get update
Hit:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:4 https://dl.winehq.org/wine-builds/ubuntu xenial InRelease
Hit:5 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:6 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu xenial InRelease
Hit:7 https://download.sublimetext.com apt/stable/ InRelease
Reading package lists... Done

$ sudo apt-cache search ^gcc-[0-9]+$
gcc-5 - GNU C compiler
gcc-6 - GNU C compiler
gcc-7 - GNU C compiler
gcc-8 - GNU C compiler
gcc-9 - GNU C compiler

$ sudo apt-get install gcc-10 g++-10
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package gcc-10
E: Unable to locate package g++-10
E: Couldn't find any package by regex 'g++-10'

@libklein
Copy link

libklein commented Dec 30, 2020

Yes, gcc-10 is not available on xenial, even in the toolchain repo (see the filter dropdown):

Screenshot_2020-12-30 Toolchain test builds “PPA for Ubuntu Toolchain Uploads (restricted)” team

@tnwjd7732
Copy link

tnwjd7732 commented Feb 24, 2021

Thank you very much!

@kiril-kirov
Copy link

kiril-kirov commented Mar 25, 2021

gcc-9[-multilib] and g++-9[-multilib] are also available for Ubuntu 12.04 LTS!

I extended the steps above, as they complain with g++ can't be slave of gcc + some additions and beautifications:

#!/bin/bash

GCC_GXX_VERSION=9
gcc_alternatives=(gcc cc)
gxx_alternatives=(g++ c++ cpp)
all_alternatives=("${gcc_alternatives[@]}" "${gxx_alternatives[@]}")

remove_alternatives() {
    alternatives=("$@")
    for alt in "${alternatives[@]}"; do
        sudo update-alternatives --remove-all $alt || continue
    done
}

install_and_set_alternatives() {
    path=$1
    shift
    alternatives=("$@")
    for alt in "${alternatives[@]}"; do
        sudo update-alternatives --install /usr/bin/$alt $alt $path 100
        sudo update-alternatives --set $alt $path
    done
}

print_green() {
    args=$@
    echo -e "\033[0;32m$args\033[0m"
}

check_versions() {
    alternatives=("$@")
    for alt in "${alternatives[@]}"; do
        print_green "$alt\t->\t`$alt --version | head -n 1`"
    done
}

install_gcc_gxx() {
    sudo apt-get update -y &&
    sudo apt-get upgrade -y &&
    sudo apt-get dist-upgrade -y &&
    sudo apt-get install build-essential software-properties-common -y &&
    sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y &&
    sudo apt-get update -y &&
    sudo apt-get install gcc-$GCC_GXX_VERSION g++-$GCC_GXX_VERSION -y
}

install_gcc_gxx
remove_alternatives "${all_alternatives[@]}"
install_and_set_alternatives "/usr/bin/gcc-$GCC_GXX_VERSION" "${gcc_alternatives[@]}"
install_and_set_alternatives "/usr/bin/g++-$GCC_GXX_VERSION" "${gxx_alternatives[@]}"

echo
echo "Check the following versions:"
check_versions "${all_alternatives[@]}"

@ivanmara555
Copy link

ivanmara555 commented Aug 5, 2021

GCC 11.x on Ubuntu 18.04 & 20.04:

sudo apt-get update -y &&
sudo apt-get upgrade -y &&
sudo apt-get dist-upgrade -y &&
sudo apt-get install build-essential software-properties-common -y &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y &&
sudo apt-get update -y &&
sudo apt-get install gcc-11 g++-11 -y &&
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 60 --slave /usr/bin/g++ g++ /usr/bin/g++-11 &&
sudo update-alternatives --config gcc

select gcc-11

@AndiHairy97
Copy link

AndiHairy97 commented Aug 17, 2021

ami@ami:~$ sudo apt-get update && \

sudo apt-get install build-essential software-properties-common -y &&
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y &&
sudo apt-get update &&
sudo apt-get install gcc-snapshot -y &&
sudo apt-get update &&
sudo apt-get install gcc-6 g++-6 -y &&
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 &&
sudo apt-get install gcc-4.8 g++-4.8 -y &&
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.8;
[sudo] password for ami:
Get:1 http://dl.google.com/linux/earth/deb stable InRelease [1,807 B]
Ign:1 http://dl.google.com/linux/earth/deb stable InRelease
Hit:2 http://ubuntu.mirror.myduniahost.com/ubuntu xenial InRelease
Hit:3 http://ubuntu.mirror.myduniahost.com/ubuntu xenial-updates InRelease
Hit:4 http://ubuntu.mirror.myduniahost.com/ubuntu xenial-backports InRelease
Get:5 https://linux.teamviewer.com/deb stable InRelease [11.9 kB]
Hit:6 http://ubuntu.mirror.myduniahost.com/ubuntu xenial-security InRelease
Get:7 https://linux.teamviewer.com/deb stable/main amd64 Packages [11.2 kB]
Get:8 https://linux.teamviewer.com/deb stable/main i386 Packages [11.0 kB]
Get:9 http://deb.anydesk.com all InRelease [5,588 B]
Fetched 41.5 kB in 1s (30.4 kB/s)
Reading package lists... Done
W: GPG error: http://dl.google.com/linux/earth/deb stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 78BD65473CB3BD13
W: The repository 'http://dl.google.com/linux/earth/deb stable InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.
N: Skipping acquire of configured file 'main/binary-i386/Packages' as repository 'http://dl.google.com/linux/earth/deb stable InRelease' doesn't support architecture 'i386'
Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version (12.1ubuntu2).
software-properties-common is already the newest version (0.96.20.10).
software-properties-common set to manually installed.
The following additional packages will be installed:
gcc-doc
The following packages will be upgraded:
gcc-doc
1 upgraded, 0 newly installed, 0 to remove and 84 not upgraded.
1 not fully installed or removed.
Need to get 0 B/3,448 B of archives.
After this operation, 10.2 kB disk space will be freed.
(Reading database ... 864713 files and directories currently installed.)
Preparing to unpack .../gcc-doc_4%3a5.3.1-1ubuntu1_amd64.deb ...
install-info: No dir file specified; try --help for more information.
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
dpkg: error processing archive /var/cache/apt/archives/gcc-doc_4%3a5.3.1-1ubuntu1_amd64.deb (--unpack):
there is no script in the new version of the package - giving up
install-info: No dir file specified; try --help for more information.
dpkg: error while cleaning up:
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
/var/cache/apt/archives/gcc-doc_4%3a5.3.1-1ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

please help me? im facing this problem for a very llong time and untill now it still not fixed

@clarkdunson
Copy link

clarkdunson commented Aug 19, 2021

Thank you very much!

@YJ-20
Copy link

YJ-20 commented Aug 25, 2021

good!

@pachiras
Copy link

pachiras commented Oct 28, 2021

Thank you! You saved me!

@bocash
Copy link

bocash commented May 29, 2022

Thank you!
gcc version 9.4.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment