我只是想编译一个简单的C程序,但出现此消息
在文件中:

#include <stdio.h>

int main(void){
  printf("Hello world\n");
  return 0;
}
在终端中:
root@javi-HUAWEI-MateBook-D:~/Documentos/Pasar a MEGASync/Apuntes/3er Curso/Redes de Banda Ancha/P1/p1-parte1/P1-1/
misprogramas# touch program1.c
root@javi-HUAWEI-MateBook-D:~/Documentos/Pasar a MEGASync/Apuntes/3er Curso/Redes de Banda Ancha/P1/p1-parte1/P1-1/
misprogramas# subl program1.c &
[1] 29061
root@javi-HUAWEI-MateBook-D:~/Documentos/Pasar a MEGASync/Apuntes/3er Curso/Redes de Banda Ancha/P1/p1-parte1/P1-1/
misprogramas# gcc program1.c
program1.c:1:10: fatal error: stdio.h: No existe el archivo o el directorio
 #include <stdio.h>
          ^~~~~~~~~
compilation terminated.
[1]+  Hecho                   subl program1.c
root@javi-HUAWEI-MateBook-D:~/Documentos/Pasar a MEGASync/Apuntes/3er Curso/Redes de Banda Ancha/P1/p1-parte1/P1-1/
misprogramas#

*编辑
我尝试使用gcc -v program1.c命令查找gcc目录,并显示以下消息:
root@javi-HUAWEI-MateBook-D:~/Documentos/Pasar a MEGASync/Apuntes/3er Curso/Redes de Banda Ancha/P1/p1-parte1/P1-1/misprogramas# gcc -v program1.c
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.4.0-1ubuntu1~18.04.1' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)
COLLECT_GCC_OPTIONS='-v' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/7/cc1 -quiet -v -imultiarch x86_64-linux-gnu program1.c -quiet -dumpbase program1.c -mtune=generic -march=x86-64 -auxbase program1 -version -fstack-protector-strong -Wformat -Wformat-security -o /tmp/ccuDXvK8.s
GNU C11 (Ubuntu 7.4.0-1ubuntu1~18.04.1) version 7.4.0 (x86_64-linux-gnu)
    compiled by GNU C version 7.4.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-linux-gnu/7/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
GNU C11 (Ubuntu 7.4.0-1ubuntu1~18.04.1) version 7.4.0 (x86_64-linux-gnu)
    compiled by GNU C version 7.4.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.19-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: fa57db1fe2d756b22d454aa8428fd3bd
program1.c:1:10: fatal error: stdio.h: No existe el archivo o el directorio
 #include <stdio.h>
          ^~~~~~~~~
compilation terminated.

最佳答案

检查/usr/include中是否存在stdio.h。
如果缺少,请运行:sudo apt install --reinstall build-essential

关于c - 错误1 :10: fatal error compilation error with the directories,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/63873136/

10-11 15:45