0

Yesterday, I installed Elementary OS Juno. This is a fresh install. When I tried to install g++ it gave me following stream of Errors. Basically some dependencies are unmet. When I tried to install them the error says:

E: Unable to correct problems, you have held broken packages.

Here is the full output:

cstayyab@ciit:~$ sudo apt install g++
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:
 g++ : Depends: gcc (>= 4:7.3.0-3ubuntu2) but it is not going to be installed
       Depends: g++-7 (>= 7.3.0-12~) but it is not going to be installed
       Depends: gcc-7 (>= 7.3.0-12~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
cstayyab@ciit:~$ sudo apt install g++-7
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:
 g++-7 : Depends: gcc-7 (= 7.3.0-16ubuntu3) but it is not going to be installed
         Depends: libstdc++-7-dev (= 7.3.0-16ubuntu3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I tried to list broken packages but I couln not find any broken package on my system.

Also ran: sudo apt install -f

But that was fine. No packages were installed or fixed.

Here is the output for sudo apt install gcc

cstayyab@ciit:~$ sudo apt-get install gcc
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 : Depends: gcc-7 (>= 7.3.0-12~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
1
  • run sudo apt upgrade
    – Maccer
    Commented Oct 20, 2018 at 12:27

2 Answers 2

0

After posting question here and trying lots of workarounds, I reinstalled Elementary OS but problem was there but then I found out that the mirror I was using in /etc/apt/sources.list was not updated so I changed all URLs to us.archive.ubuntu.com and the default due to timezone was pk.archive.ubuntu.com which was outdated mirror.

After changing the mirrors my problem was solved.

I am posting this answer so if someone else have this problem they might try to change mirrors.

0

Thanks. All I did was apt install build-essential which installed the required compilers for me.

1
  • That was not true in my case. I tried that also but as I mentioned in my answer to this question , I had wrong mirror selected so I changed them and everything went fine.
    – cstayyab
    Commented Oct 22, 2018 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.