14

When i try to install libstdc++ using:

sudo apt-get install libstdc++

I am getting the below error in ubuntu. Do you have any idea about it?

The following packages have unmet dependencies:
 libstdc++-4.8-doc : Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                     Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
                     Conflicts: libstdc++6-4.7-doc but 4.7.3-12ubuntu1 is to be installed
 libstdc++-4.9-doc : Conflicts: libstdc++-4.8-doc but 4.8.5-2ubuntu1~14.04.1 is to be installed
                     Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                     Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
                     Conflicts: libstdc++6-4.7-doc but 4.7.3-12ubuntu1 is to be installed
 libstdc++-5-doc : Conflicts: libstdc++-4.8-doc but 4.8.5-2ubuntu1~14.04.1 is to be installed
                   Conflicts: libstdc++-4.9-doc but 4.9.3-8ubuntu2~14.04 is to be installed
                   Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                   Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
                   Conflicts: libstdc++6-4.7-doc but 4.7.3-12ubuntu1 is to be installed
 libstdc++6-4.6-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
 libstdc++6-4.6-doc : Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
 libstdc++6-4.7-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
 libstdc++6-4.7-doc : Conflicts: libstdc++6-4.4-doc but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-doc but 4.6.4-6ubuntu2 is to be installed
 libstdc++6-4.8-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
                      Conflicts: libstdc++6-4.7-dbg but 4.7.3-12ubuntu1 is to be installed
 libstdc++6-4.8-dbg-armhf-cross : Conflicts: libstdc++6-4.7-dbg-armhf-cross but 4.7.3-11ubuntu1cross1.85 is to be installed
 libstdc++6-4.9-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
                      Conflicts: libstdc++6-4.7-dbg but 4.7.3-12ubuntu1 is to be installed
                      Conflicts: libstdc++6-4.8-dbg but 4.8.5-2ubuntu1~14.04.1 is to be installed
 libstdc++6-5-dbg : Conflicts: libstdc++6-4.4-dbg but 4.4.7-8ubuntu1 is to be installed
                    Conflicts: libstdc++6-4.6-dbg but 4.6.4-6ubuntu2 is to be installed
                    Conflicts: libstdc++6-4.7-dbg but 4.7.3-12ubuntu1 is to be installed
                    Conflicts: libstdc++6-4.8-dbg but 4.8.5-2ubuntu1~14.04.1 is to be installed
                    Conflicts: libstdc++6-4.9-dbg but 4.9.3-8ubuntu2~14.04 is to be installed
E: Unable to correct problems, you have held broken packages.
  • Did you recently add any ppas? – Raphael Jan 28 '16 at 7:36
  • 1
    There isn't actually a package called libstdc++ (possibly you are trying to install libstdc++6? Because of the ++ characters, when apt doesn't find an exact match it treats the package name as a regular expression so in this case it's trying to install any package whose name matches libstd followed by one or more c - many of which conflict, as you can see. – steeldriver Jan 28 '16 at 13:21
  • @steeldriver: that is clearly the answer and imho should be an answer rather than a comment (although it would help to be able to explain how to avoid treating the string as a regex). The manpage for apt says that it will treat package names as regexes if they include ., ? or * without mentioning +, so the behaviour is not exactly expected. – rici Jan 28 '16 at 17:14
13

First run these commands

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install build-essential
sudo apt-get install aptitude

and then try

sudo apt-get install libstdc++6

or try this search result and install one desired package from listed http://packages.ubuntu.com/search?keywords=libstdc%2B%2B

  • 2
    +1 Good answer, but isn't the libstdc++ included in the build-essentials? – Kev Inski Jan 28 '16 at 6:34
  • 6
    Oh and why installing aptitude if you don't use it for installing libstdc++6? – Kev Inski Jan 28 '16 at 6:39
  • 2
    Thanks for your reply Kev. I tried to give some sort of possibilities in case of not success. And aptitude for handling his error. – M.A.K. Ripon Jan 28 '16 at 7:07
  • sudo apt-get update apt-get: error while loading shared libraries: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: invalid ELF header – mvladk Jan 31 at 8:12
11

There isn't actually a package called libstdc++ (possibly you are trying to install libstdc++6?)

When apt doesn't find an exact match to a package name, it treats the given string as a regular expression. In this case the ++ causes it to try to install any package whose name matches libstd followed by one or more c - many of which conflict, as you can see.

Unfortunately I have never managed to figure out how to turn off this behaviour (nothing I have tried in the past using escape characters has seemed to work) - the only solution I know is to be careful to give an exact package name where any regex characters might be misinterpreted, and to make sure the package catalog is up-to-date i.e.

sudo apt-get update
sudo apt-get install libstdc++6
  • this should be accepted. Concerning the turn-off: one could write an alias or function which wraps the package name inside a ^PACKAGE$ – Blauhirn May 17 '17 at 23:07
2
LD_LIBRARY_PATH=/usr/local/lib64/:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
  • 6
    Could you explain why the user must do this and what each command does? (just in case someone else reads your answer and decides to just copy-paste it for the wrong problem?) ;-) – Fabby Oct 22 '16 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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