0

I am trying to install gcc to run a C/C++ program in Visual Studio Code, but I am not able to install gcc.

I tried

sudo apt-get update
sudo apt install build-essential

And it shows an error Unable to correct problems, you have held broken packages

How can I resolve this error and install gcc?

cocomac
  • 3,043
  • 3
  • 16
  • 49
Rohit Roniya
  • 21
  • 1
  • 1
  • 1
  • You updated the database but did you update the softwares? sudo apt upgrade? – David Mar 16 '22 at 16:22
  • 4
    [Edit your question](https://askubuntu.com/posts/1397874/edit) to show the complete output of `sudo apt update` AND complete input/output of any apt action showing the error. – user535733 Mar 16 '22 at 16:29
  • Yes, please post the output of `sudo apt update` so that we can identify where the issue went wrong and provide an accurate answer. – Logan Mar 16 '22 at 16:44
  • A similar error that a user had is also on this post: https://askubuntu.com/questions/1215399/cannot-install-or-uninstall-with-apt/1215407#1215407 – Logan Mar 16 '22 at 16:48

1 Answers1

1

First, run:

sudo apt update
sudo apt dist-upgrade

Then, run:

sudo apt -f install

Please post any errors.

mchid
  • 42,315
  • 7
  • 94
  • 147