如何为WSL(linux的windows子系统)安装GCC和GDB?

如何为WSL(linux的windows子系统)安装GCC和GDB?,windows,gcc,gdb,windows-subsystem-for-linux,Windows,Gcc,Gdb,Windows Subsystem For Linux,我需要gcc来编译c代码,但无法在wsl上安装gcc。我尝试了sudo-apt-get-install-gcc,但没有成功。这就是错误所在 hack@DESKTOP-VMQA3JB:~$ sudo apt-get install gcc Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This

我需要gcc来编译c代码,但无法在wsl上安装gcc。我尝试了
sudo-apt-get-install-gcc
,但没有成功。这就是错误所在

hack@DESKTOP-VMQA3JB:~$ sudo apt-get install gcc
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gcc : Depends: gcc-9 (>= 9.2.1-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
我不知道要安装的依赖项。也请帮我处理gdb。谢谢。

您需要:

  • 更新和升级:
  • $sudo-apt-get-update&&sudo-apt-get-upgrade-y
    

    2.清洁不需要的包装:

    $sudo apt自动删除-y
    

  • 安装GCC:
  • $sudo apt get安装gcc-y
    

  • 检查并确认已安装的gcc版本:
  • gcc--version
    

    在运行
    sudo-apt-get-update
    sudo-apt-get-upgrade
    后,您是否仍然存在问题?是的,它在更新和升级后工作。。非常感谢。您好,我只是想知道“sudo apt get upgrade-y”中的“-y”是什么意思?@分开它意味着回答y(是)如果有任何问题需要确认,请继续。