Linux 错误:没有包含搜索 stdio.h 的路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4236827/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 00:02:25  来源:igfitidea点击:

error: no include path in which to search for stdio.h

clinuxgccbash

提问by Joey Adams

I used to be able to compile C programs, but now I can't:

我曾经能够编译 C 程序,但现在我不能:

$ cat helloworld.c
#include <stdio.h>

int main(void)
{
    printf("Hello, world!\n");
    return 0;
}

$ gcc helloworld.c
helloworld.c:1:19: error: no include path in which to search for stdio.h

Yes, I do have /usr/include/stdio.h. Yes, build-essentialsis installed.

是的,我有/usr/include/stdio.h。是的,build-essentials已安装。

This problem began after I modified my ~/.bashrcto run a program installed in my user directory. I know this is what's wrong because if I remove ~/.bashrc, it works.

这个问题是在我修改我的~/.bashrc以运行安装在我的用户目录中的程序之后开始的。我知道这有什么问题,因为如果我删除~/.bashrc,它就可以工作。

What environment variable would be shadowing /usr/includeas an include path?

什么环境变量会/usr/include作为包含路径隐藏?

采纳答案by Joey Adams

The problem was that I had another GCC in my PATH:

问题是我的 PATH 中有另一个 GCC:

$ which gcc
/home/joey/gcc4ti/bin/gcc

When I was trying to compile "Hello World", it was running a compiler for a 68000, not my system compiler :D

当我尝试编译“Hello World”时,它运行的是 68000 的编译器,而不是我的系统编译器:D

I had this in my ~/.bashrc:

我有这个~/.bashrc

export PATH="/home/joey/gcc4ti/bin:$PATH"

Because paths are scanned in order, the gccin /home/joey/gcc4ti/binis seen first. I changed it to:

因为路径是按顺序扫描的,所以首先看到gccin /home/joey/gcc4ti/bin。我把它改成:

export PATH="$PATH:/home/joey/gcc4ti/bin"