Linux c程序中包含的头文件的默认路径是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7834152/
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
what is default path for header file included in c program?
提问by Jeegar Patel
see if i write in any c file like
看看我是否写在任何c文件中
#include "header.h"
then it will search this file in current directory
然后它将在当前目录中搜索此文件
but when i write
但是当我写
#include <header.h>
then where it will go to find this file ? what is defualt path for header file included in c program?
那么它会去哪里找到这个文件呢?c程序中包含的头文件的默认路径是什么?
see i have installed gstreamer in /usr/local but when i am including
看到我在 /usr/local 中安装了 gstreamer 但是当我包括在内时
#include <gst/gst.h>
i am geeting fatal error: gst/gst.h: No such file or directory
我在听 fatal error: gst/gst.h: No such file or directory
How can i remove this error?
我怎样才能消除这个错误?
采纳答案by cnicutar
The path searched depends on the implementation (and current configuration). The correct way to find the include path is to use pkg-config
搜索的路径取决于实现(和当前配置)。找到包含路径的正确方法是使用pkg-config
pkg-config --cflags gstreamer
回答by 0xd
you can find those files in:
您可以在以下位置找到这些文件:
/usr/include
回答by mouviciel
The default path for <>
stuff is /usr/include
, at least on Unix.
至少在 Unix 上,<>
东西的默认路径是/usr/include
。
You can add as many default paths as you want with -I /my/new/path
compiler option.
您可以使用-I /my/new/path
编译器选项添加任意数量的默认路径。
回答by Nate
Try running gcc -v -E -
. When I do, part of the output is as follows:
尝试运行gcc -v -E -
。当我这样做时,部分输出如下:
#include <...> search starts here:
/usr/lib/gcc/i686-linux-gnu/4.6.1/include
/usr/local/include
/usr/lib/gcc/i686-linux-gnu/4.6.1/include-fixed
/usr/include/i386-linux-gnu
/usr/include
It's not an answer to the gstreamer question, but I hope this still helps!
这不是 gstreamer 问题的答案,但我希望这仍然有帮助!
Pulled from here
从这里拉
回答by Tio Pepe
The default paths are
默认路径是
/usr/local/include
/usr/include
If you use another path, you can add in your compile command with -I
flag. In your case, assuming you have a /usr/local/gst/include
directory, you may add -I/usr/local/gst/include
and use #include <whatever_you_need.h>
如果使用其他路径,则可以在编译命令中添加-I
标志。在你的情况下,假设你有一个/usr/local/gst/include
目录,你可以添加-I/usr/local/gst/include
和使用#include <whatever_you_need.h>
回答by John Doe
`gcc -print-prog-name=cc1` --verbose