无法在Ubuntu 20.04 WSL中安装GCC

gudnpqoy  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(406)

我已经尝试在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?

nimxete2

nimxete21#

我可以使用***sudo apt install gcc***安装GCC
如果这样做不起作用,请尝试升级您的软件包。
我发现YouTube上的https://www.systranbox.com/how-to-install-gcc-on-wsl-linux/视频在这方面有点帮助。

相关问题