简体   繁体   中英

Unable to install g++ in ubuntu 20.04

I have seen some questions similar to this on this website old latest .
But none of them have been answered and I am unable to comment there because I have less reputation points.

When I run sudo apt install g++ I get the following error:

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:
 g++ : Depends: gcc (= 4:9.3.0-1ubuntu2) but it is not going to be installed
       Depends: g++-9 (>= 9.3.0-3~) but it is not going to be installed
       Depends: gcc-9 (>= 9.3.0-3~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

When I run sudo apt install build-essential I get the following error:

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:
 build-essential : Depends: gcc (>= 4:9.2) but it is not going to be installed
                   Depends: g++ (>= 4:9.2) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I need to install g++ in ubuntu20.04.

Thanks for the help!

I found a work around by installing aptitude first.
I followed the following steps:

sudo apt-get install aptitude
Then aptitude gives a list of packages (none of which were installed)
and asks to keep those packages in the same version. Choose No ( n ).
Then aptitude asks to downgrade some packages. Choose Yes ( Y ).

Finally run the command: sudo aptitude install build-essential

After running the above command g++ was already install and I didn't need to separately install it.\

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM