错误:没有可在其中搜索 stdio.h 的包含路径

发布于 2024-10-03 18:11:03 字数 500 浏览 2 评论 0原文

我以前能够编译 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

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

在我修改 ~/.bashrc 以运行用户目录中安装的程序后,此问题开始出现。我知道这是错误的,因为如果我删除 ~/.bashrc,它就会起作用。

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

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

$ 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-essentials is installed.

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尴尬癌患者 2024-10-10 18:11:03

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

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

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

我在我的 ~/.bashrc 中有这个

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

由于路径是按顺序扫描的,因此首先会看到/home/joey/gcc4ti/bin中的gcc。我把它改为:

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

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

$ 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

I had this in my ~/.bashrc:

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

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

export PATH="$PATH:/home/joey/gcc4ti/bin"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文