无法在 Ubuntu 20.04 WSL 中安装 GCC

发布于 2025-01-16 01:29:21 字数 1861 浏览 3 评论 0原文

我尝试在 WSL 上的 Ubuntu 20.04 中安装 gcc :

apt -y install gcc 返回错误:

Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:9.3.0-1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 194 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up gcc (4:9.3.0-1ubuntu2) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
 installed gcc package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 gcc
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试使用以下命令修复它:

sudo dpkg --purge --force-depends gcc 
sudo apt-get autoremove -y
sudo apt-get autoclean -y
sudo apt-get clean gcc
sudo apt-get install gcc

但随后出现错误:

    root@LAP123:/home/my_user# sudo apt-get install gcc
   .......
Setting up desktop-file-utils (0.24-1ubuntu3) ...
    /var/lib/dpkg/info/desktop-file-utils.postinst: 5: update-desktop-database: not found
    dpkg: error processing package desktop-file-utils (--configure):
     installed desktop-file-utils package post-installation script subprocess returned error exit status 127
    Setting up gcc (4:9.3.0-1ubuntu2) ...
    update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
    dpkg: error processing package gcc (--configure):
     installed gcc package post-installation script subprocess returned error exit status 2
    Processing triggers for man-db (2.9.1-1) ...
    Errors were encountered while processing:
     desktop-file-utils
     gcc
    E: Sub-process /usr/bin/dpkg returned an error code (1)

如何在 Ubuntu 中安装 gcc?

I have tried to install gcc in Ubuntu 20.04 on WSL :

apt -y install gcc return error:

Reading package lists... Done
Building dependency tree
Reading state information... Done
gcc is already the newest version (4:9.3.0-1ubuntu2).
0 upgraded, 0 newly installed, 0 to remove and 194 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up gcc (4:9.3.0-1ubuntu2) ...
update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
dpkg: error processing package gcc (--configure):
 installed gcc package post-installation script subprocess returned error exit status 2
Errors were encountered while processing:
 gcc
E: Sub-process /usr/bin/dpkg returned an error code (1)

I tried to fix it with :

sudo dpkg --purge --force-depends gcc 
sudo apt-get autoremove -y
sudo apt-get autoclean -y
sudo apt-get clean gcc
sudo apt-get install gcc

But then I got error :

    root@LAP123:/home/my_user# sudo apt-get install gcc
   .......
Setting up desktop-file-utils (0.24-1ubuntu3) ...
    /var/lib/dpkg/info/desktop-file-utils.postinst: 5: update-desktop-database: not found
    dpkg: error processing package desktop-file-utils (--configure):
     installed desktop-file-utils package post-installation script subprocess returned error exit status 127
    Setting up gcc (4:9.3.0-1ubuntu2) ...
    update-alternatives: error: alternative path /usr/bin/gcc doesn't exist
    dpkg: error processing package gcc (--configure):
     installed gcc package post-installation script subprocess returned error exit status 2
    Processing triggers for man-db (2.9.1-1) ...
    Errors were encountered while processing:
     desktop-file-utils
     gcc
    E: Sub-process /usr/bin/dpkg returned an error code (1)

How can I install gcc in my Ubuntu?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

明月松间行 2025-01-23 01:29:21

我可以使用 sudo apt install gcc 安装 GCC,

如果这不起作用,请尝试升级您的软件包。

我在 https://www.systranbox 找到了 YouTube 视频.com/how-to-install-gcc-on-wsl-linux/ 在这方面有些帮助。

I was able to install GCC with sudo apt install gcc

if that doesn't work try upgrading your packages.

I found the YouTube video at https://www.systranbox.com/how-to-install-gcc-on-wsl-linux/ somewhat helpful in that regard.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文