GCC 致命错误:stdio.h:没有这样的文件或目录 [英] GCC fatal error: stdio.h: No such file or directory

查看:89
本文介绍了GCC 致命错误:stdio.h:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 GCC 4.9(实验性)在 OS X 10.9 上用 C 编译程序.出于某种原因,我在编译时收到以下错误:

I'm trying to compile a program in C on OS X 10.9 with GCC 4.9 (experimental). For some reason, I'm getting the following error at compile time:

gcc: fatal error: stdio.h: No such file or directory

然后我尝试了一个简单的 Hello World 程序:

I then tried a simple Hello World program:

#include <stdio.h>

int main(int argc, const char *argv[])
{
    printf("Hello, world!");
    return 0;
}

同样,在运行 gcc -o ~/hello ~/hello.c 时,我遇到了同样的错误.我正在使用 gcc 的实验版本,但似乎不可能有一个在导入 stdio 时生成错误的版本.导致此问题的原因是什么,如何解决?

Again, upon running gcc -o ~/hello ~/hello.c, I got the same error. I'm using an experimental version of gcc, but it seems implausible that there would be a release which generated errors upon importing stdio. What could be causing this issue, and how can it be fixed?

推荐答案

Mac OS X

我也有这个问题(通过 Macports 编译器遇到).以前版本的 Xcode 可以让您通过 xcode/Preferences 安装命令行工具,但是 xcode5 没有在 GUI 中提供命令行工具选项,所以我认为它现在已自动包含在内.尝试运行此命令:

Mac OS X

I had this problem too (encountered through Macports compilers). Previous versions of Xcode would let you install command line tools through xcode/Preferences, but xcode5 doesn't give a command line tools option in the GUI, that so I assumed it was automatically included now. Try running this command:

xcode-select --install

Ubuntu

(根据此答案)

sudo apt-get install libc6-dev

Alpine Linux

(根据此评论)

apk add libc-dev

这篇关于GCC 致命错误:stdio.h:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆