I'm new to Ubuntu and trying to install g++ for development but every time I try to install g++ using

sudo apt-get install g++

I get the following error. Kindly help me in resolving this issue. Thanks.

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

2 Answers 2


First, to install g++ and everything it needs to work, you should install build-essential package, not g++ alone. I additionally recomend QtCreator as IDE.
Your problem with apt-get will likely be resolved by doing

sudo apt-get -f install

Okay so I figured that something was wrong with updates coming from local server of Ubuntu so I changed it from /etc/apt/source.list to Main server and then used build-essential to build all necessary components including g++. Thanks for help @Barafu.

  • Next time you should change mirror from System Settings - Software and Updates - Download from: tab. My default country mirror was broken too, so I had to select exact one. Mar 21, 2015 at 12:46

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