首页 > 解决方案 > 如何为 WSL(Linux 的 Windows 子系统)安装 GCC 和 GDB?

问题描述

我需要 gcc 来编译 ac 代码并且无法在 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。谢谢你。

标签: windowsgccgdbwindows-subsystem-for-linux

解决方案


你需要:

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

在此处输入图像描述

2.清理不需要的包:

$ sudo apt autoremove -y

在此处输入图像描述

  1. 安装 GCC:
$ sudo apt-get install gcc -y

在此处输入图像描述

  1. 检查并确认安装的 gcc 版本:
gcc --version

在此处输入图像描述


推荐阅读