我想在 WSL-2 上运行的 Ubuntu 22.04.3 LTS 上编译我的 c 程序。尽我所能,我不断收到以下错误:
> myFile1.c:1:10: fatal error: stdio.h: No such file or directory
> 1 | #include <stdio.h>
> | ^~~~~~~~~
> compilation terminated.
标准 gcc 头文件似乎从未安装在 /usr/include 中
有人知道如何解决这个问题吗?谢谢!
我之前尝试过的:
我一开始是跑的...
$ sudo apt install gcc
然后...
$ sudo apt install gcc --fix-missing
然后...
$ sudo apt-get update && sudo apt-get upgrade -y
$ sudo apt autoremove -y
$ sudo apt-get install gcc -y
但是,这些都没有解决问题。当我运行
gcc myFile.c -o myProgram.exe && ./myProgram
时,我得到与上面相同的错误。
您需要安装
glibc
或其他libc实现。我建议安装 build-essentials
软件包。
apt upgrade
apt install build-essentials