Install g++ ubuntu 14.04 Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed

I just typed:

sudo apt-get install g++

and got:

The following packages have unmet dependencies:
 g++ : Depends: g++-4.8 (>= 4.8.2-5~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

I tried also as per suggestions in other forums:

sudo apt-get update

and

sudo apt-get -f install

None solved my problem. Please help if you know the answer.

EDIT:

As per the suggestion placed in the comment, I tried:

sudo apt-cache policy g++-4.8

and got the following output:

g++-4.8:
  Installed: (none)
  Candidate: 4.8.2-19ubuntu1
  Version table:
     4.8.2-19ubuntu1 0
        500 http://ca.archive.ubuntu.com/ubuntu/ trusty/main amd64 Packages

By trying:

sudo apt-get install g++-4.8

I got:

The following packages have unmet dependencies:
 g++-4.8 : Depends: gcc-4.8-base (= 4.8.2-19ubuntu1) but 4.8.4-2ubuntu1~14.04 is to be installed
           Depends: gcc-4.8 (= 4.8.2-19ubuntu1) but 4.8.4-2ubuntu1~14.04 is to be installed
           Depends: libstdc++-4.8-dev (= 4.8.2-19ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Solution 1:

The problem is:

libstdc++-4.8-dev : Depends: gcc-4.8-base (= 4.8.2-19ubuntu1) but 4.8.4-2ubuntu1~14.04 is to be installed

Why? That's why:

  • libstdc++-4.8-dev in the main repositories depends on libstdc++-4.8-dev=4.8.2-19ubuntu1

  • libstdc++-4.8-dev in the updates repository depends on libstdc++-4.8-dev=4.8.4-2ubuntu1~14.04, which is installed in your system


The solution?

My first choice is, enable the update repository again:

  • Open Software & Updates and the tab Updates

  • Select trusty-updates and trusty-security and click Close

    If someone has a version for the terminal, then please let me know.

    enter image description here

  • Reload

    enter image description here

  • Install

    sudo apt-get install g++
    

My second choice, downgrade

Hmm, I would say, that's a bad idea =)