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,394
  • You updated the database but did you update the softwares? sudo apt upgrade? – David Mar 16 '22 at 16:22
  • 4
    Edit your question 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
  • 43,546
  • 8
  • 97
  • 150