Как правильно обновить gcc7.3 до gcc8 в Ubuntu 18.04.01 LTS?

В моем LTS Ubuntu 18.04:

marco@PC:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

У меня есть gcc версия 7.3.0:

marco@PC:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu    
7.3.0-21ubuntu1~16.04' --with-bugurl=file:///usr/share/doc/gcc-
7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++
--prefix=/usr --with-gcc-major-version-only --program-suffix=-7 
--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 --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-offload-targets=nvptx-none 
--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 7.3.0 (Ubuntu 7.3.0-21ubuntu1~16.04)

И я хочу установить gcc-8:

marco@PC:~$ sudo apt-get install gcc-8
[sudo] password for marco:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-8 : Depends: cpp-8 (= 8.1.0-1ubuntu1) but it is not going to be   
installed
         Depends: gcc-8-base (= 8.1.0-1ubuntu1) but 8.1.0-5ubuntu1~16.04 
is to be installed
         Depends: libgcc-8-dev (= 8.1.0-1ubuntu1) but it is not going to 
be installed
E: Unable to correct problems, you have held broken packages.

После подсказок, найденных здесь askUbuntu:Unable для исправления проблем, Вы держали поврежденные пакеты

marco@PC:~$ sudo apt-get update
[sudo] password for marco:
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 88.7 kB in 1s (107 kB/s)
Reading package lists... Done
marco@PC:~$ sudo apt-get autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
marco@PC:~$ dpkg --get-selections | grep hold
marco@PC:~$ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
marco@PC:~$ sudo apt-get update
Hit:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:2 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Fetched 88.7 kB in 1s (123 kB/s)
Reading package lists... Done

Затем я проверил используемый репозиторий PPA, как предложено:

marco@PC:~$ apt-cache policy gcc-8 cpp-8 libgcc-8-dev
gcc-8:
  Installed: (none)
  Candidate: 8.1.0-1ubuntu1
  Version table:
     8.1.0-1ubuntu1 500
        500 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu    
bionic/main amd64 Packages
     8-20180414-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64  
Packages
cpp-8:
  Installed: (none)
  Candidate: 8.1.0-1ubuntu1
  Version table:
     8.1.0-1ubuntu1 500
        500 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu  
bionic/main amd64 Packages
     8-20180414-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64   
Packages
libgcc-8-dev:
  Installed: (none)
  Candidate: 8.1.0-1ubuntu1
  Version table:
     8.1.0-1ubuntu1 500
        500 http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu 
bionic/main amd64 Packages
     8-20180414-1ubuntu2 500
        500 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64      
        Packages

Я затем удалил PPA ubuntu-toolchain-r/test:

sudo add-apt-repository --remove 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 removing it.

Но проблема остается:

marco@PC:~$ sudo apt-get install gcc-8
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc-8 : Depends: cpp-8 (= 8-20180414-1ubuntu2) but it is not going to be 
installed
         Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.1.0-5ubuntu1~16.04  
is to be installed
         Depends: libgcc-8-dev (= 8-20180414-1ubuntu2) but it is not going to 
be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install cpp-8
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cpp-8 : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but 8.1.0-5ubuntu1~16.04 
 is to be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install gcc-8-base
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-8-base is already the newest version (8.1.0-5ubuntu1~16.04).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

marco@PC:~$ sudo apt-get install libgcc-8-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libgcc-8-dev : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but   
8.1.0-5ubuntu1~16.04 is to be installed
                Depends: libasan5 (>= 8.1.0-1ubuntu1) but it is not going
 to be installed
                Depends: libubsan1 (>= 8.1.0-1ubuntu1) but it is not 
 going to be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install libasan5
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libasan5 : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but   
 8.1.0-5ubuntu1~16.04 is to be installed
E: Unable to correct problems, you have held broken packages.

marco@PC:~$ sudo apt-get install libubsan1
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libubsan1 : Depends: gcc-8-base (= 8.1.0-1ubuntu1) but     
 8.1.0-5ubuntu1~16.04 is to be installed
E: Unable to correct problems, you have held broken packages.

Так... это кажется что для установки gcc-8, я должен установить другие пакеты, которые зависят от других пакетов, которые зависят themself от gcc-8-base, который уже правильно установлен.

И это говорит "поврежденные пакеты"... поэтому, как решить проблему? Нетерпеливое ожидание добрых подсказок и справки. Marco

Обновление:

marco@PC:~$ sudo apt-get install ppa-purge
Reading package lists... Done
Building dependency tree
Reading state information... Done
ppa-purge is already the newest version (0.2.8+bzr63).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

marco@PC:~$ sudo ppa-purge ppa:ubuntu-toolchain-r/test
Updating packages lists
PPA to be removed: ubuntu-toolchain-r test
Warning:  Could not find package list for PPA: ubuntu-toolchain-r test

marco@PC:~$ sudo apt-get update
Hit:1 http://cz.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:3 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:4 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Hit:5 http://us.archive.ubuntu.com/ubuntu bionic-backports InRelease
Reading package lists... Done

marco@PC:~$ sudo apt install gcc-8-base gcc-8 cpp-8 libgcc-8-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc-8-base is already the newest version (8.1.0-5ubuntu1~16.04).
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 cpp-8 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.1.0-5ubuntu1~16.04  
 is to be installed
 gcc-8 : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but 8.1.0-5ubuntu1~16.04
 is to be installed
 libgcc-8-dev : Depends: gcc-8-base (= 8-20180414-1ubuntu2) but    
 8.1.0-5ubuntu1~16.04 is to be installed
                 Depends: libasan5 (>= 8-20180414-1ubuntu2) but it is not
                  going to be installed
                 Depends: libubsan1 (>= 8-20180414-1ubuntu2) but it is not 
                  going to be installed
 E: Unable to correct problems, you have held broken packages.

После установки способности я следовал за предложениями, обозначенными способностью. Теперь у меня есть эта ситуация:

marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
  2            /usr/bin/gcc-8   80        manual mode


 marco@PC:~$ g++ -std=c++17 HelloWorld.cpp -oHelloWorld
marco@PC:~$ ./HelloWorld
Hello World!

Если я принимаю решение использовать gcc-8:

marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
* 0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
  2            /usr/bin/gcc-8   80        manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/bin/gcc-8 to provide /usr/bin/gcc (gcc) in 
manual mode
update-alternatives: warning: skip creation of /usr/bin/g++ because 
associated file /usr/bin/g++-8 (of link group gcc) doesn't exist


marco@PC:~$ sudo aptitude install g++-8
The following NEW packages will be installed:
  g++-8 libstdc++-8-dev{a}
0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 9,623 kB of archives. After unpacking 43.7 MB will be used.
Do you want to continue? [Y/n/?] Y
Get: 1 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 libstdc++-8-
dev amd64 8-20180414-1ubuntu2 [1,536 kB]
Get: 2 http://us.archive.ubuntu.com/ubuntu bionic/universe amd64 g++-8 amd64 
8-20180414-1ubuntu2 [8,088 kB]
Fetched 9,623 kB in 1s (7,165 kB/s)
Selecting previously unselected package libstdc++-8-dev:amd64.
(Reading database ... 92421 files and directories currently installed.)
Preparing to unpack .../libstdc++-8-dev_8-20180414-1ubuntu2_amd64.deb ...
Unpacking libstdc++-8-dev:amd64 (8-20180414-1ubuntu2) ...
Selecting previously unselected package g++-8.
Preparing to unpack .../g++-8_8-20180414-1ubuntu2_amd64.deb ...
Unpacking g++-8 (8-20180414-1ubuntu2) ...
Setting up libstdc++-8-dev:amd64 (8-20180414-1ubuntu2) ...
Setting up g++-8 (8-20180414-1ubuntu2) ...
Processing triggers for man-db (2.8.3-2) ...


marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

  Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
* 2            /usr/bin/gcc-8   80        manual mode

Press <enter> to keep the current choice[*], or type selection number:
update-alternatives: warning: forcing reinstallation of alternative /usr/bin
/gcc-8 because link group gcc is broken

Теперь, после перезагрузки, это кажется работой:

marco@PC:~$ sudo update-alternatives --config gcc
There are 2 choices for the alternative gcc (providing /usr/bin/gcc).

      Selection    Path            Priority   Status
------------------------------------------------------------
  0            /usr/bin/gcc-7   700       auto mode
  1            /usr/bin/gcc-7   700       manual mode
* 2            /usr/bin/gcc-8   80        manual mode

Press <enter> to keep the current choice[*], or type selection number:
marco@PC:~$ g++ -std=c++17 HelloWorld.cpp -oHelloWorld
marco@PC:~$ ./HelloWorld
Hello World!

marco@PC:~$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/8/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu   
8-20180414-1ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs  
--enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr   
--with-gcc-major-version-only --with-as=/usr/bin/x86_64-linux-gnu-as --with- 
ld=/usr/bin/x86_64-linux-gnu-ld --program-suffix=-8 --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 --enable-
default-pie --with-system-zlib --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-offload-targets=nvptx-none --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 8.0.1 20180414 (experimental) [trunk revision 259383] (Ubuntu 
8-20180414-1ubuntu2)
3
задан 3 September 2018 в 13:54

1 ответ

Несовместимый репозиторий (репозитории) от 16,04 от в Ваших источниках программного обеспечения вмешивается в установку других пакетов в Ubuntu 18.04 и порождении сообщения об ошибке о поврежденных пакетах, поэтому снесите те несовместимые репозитории с ppa-чисткой от Ваших источников программного обеспечения.

Затем Вы сможете установить пакеты, в которых Вы нуждаетесь из репозиториев Ubuntu 18.04 по умолчанию. Откройте терминал и тип:

sudo apt-get install ppa-purge
sudo apt update 
sudo apt install aptitude 
sudo aptitude install libubsan1 libasan5 libgcc-8-dev gcc-8-base gcc-8 cpp-8 g++-8 

Следуйте за предложениями способности, если существует проблема зависимости после выполнения последней команды, потому что способность немного умна о предложении, как решить вопросы зависимости, которые вызываются поврежденными пакетами.

4
ответ дан 1 December 2019 в 15:49

Другие вопросы по тегам:

Похожие вопросы: