Linux sys/types.h 位于何处?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11823063/
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
Where is sys/types.h located?
提问by mko
I just found out that the <stdlib.h>
and <stdio.h>
headers are located in the /usr/include
folder in Ubuntu server, but I don't find sys/types.h
.
我刚刚发现<stdlib.h>
和<stdio.h>
标头位于/usr/include
Ubuntu 服务器的文件夹中,但我没有找到sys/types.h
.
And I start to suspect the compiler won't actually use the header file in the /usr/include
folder.
我开始怀疑编译器实际上不会使用文件/usr/include
夹中的头文件。
Is this true, and where is the file located?
这是真的吗,文件在哪里?
采纳答案by paxdiablo
My Debian box (and hopefully Ubuntu haven't butchered it toomuch in their zeal) has it in /usr/include/sys/types.h
.
我的 Debian 盒子(希望 Ubuntu 没有因为他们的热情而对它进行过多的屠杀)在/usr/include/sys/types.h
.
Your best bet is to first execute:
最好的办法是首先执行:
find /usr/include -name types.h
then:
然后:
find / -name types.h
if you don't find it in the first one.
如果你没有在第一个中找到它。
However, keep in mind that the development stuff may not even be installed.I would imaging a server box is meant to be used as a server and it wouldn't surprise me if the compiler and a bunch of other stuff was not part of the default install (but it would have a lot of server things like ftpd
or Apache
and so on).
但是,请记住,甚至可能不会安装开发内容。我会想象一个服务器盒被用作服务器,如果编译器和一堆其他东西不是默认安装的一部分,我不会感到惊讶(但它会有很多服务器东西,比如ftpd
或Apache
和很快)。
If the compiler is locating it somewhere and you just don't know where, you can use something like:
如果编译器将它定位在某处而您只是不知道在哪里,则可以使用以下内容:
echo "#include <sys/types.h>" | gcc -E -x c - | grep /types.h
to find out where it's getting it from.
找出它从哪里得到它。
Or:
或者:
echo "#include <stdio.h>" | gcc -E -x c - | grep /stdio.h
for the other header you're worried about.
对于您担心的另一个标题。
Aside: That
gcc
command line stops after the pre-processing phase (-E
), forces the file to be treated as C source code (-x c
) and retrieves the program from standard input (-
), in this case from theecho
statement.
旁白:该
gcc
命令行在预处理阶段 (-E
)之后停止,强制将文件视为 C 源代码 (-x c
) 并从标准输入 (-
)检索程序,在本例中为echo
语句。
The final grep
just strips out the unimportant lines.
最后grep
只是去掉不重要的行。
回答by wallyk
On Linux, types.h
should be in /usr/include/sys/types.h
.
在 Linux 上,types.h
应该在/usr/include/sys/types.h
.
回答by Dmitry Zagorulkin
If you have locate command available you can simply use locate
:
如果您有可用的 locate 命令,您可以简单地使用locate
:
-bash-3.2$ locate sys/types.h
/usr/include/sys/types.h
/usr/lib/syslinux/com32/include/sys/types.h
-bash-3.2$
It's the quickest and simplest way to do it.
这是最快和最简单的方法。
回答by rascaL raajA
The file sys/types.h
is located at the /usr/include/sys/types.h
该文件sys/types.h
位于/usr/include/sys/types.h
if u get this kind of Fatal Error:
如果您遇到这种致命错误:
.../linux/linux_types.h:146:38: fatal error: /usr/include/sys/types.h: No
such file or directory
Fixby using the following code:
使用以下代码修复:
sudo apt-get install build-essential flex libelf-dev libc6-dev-amd64 binutils-dev libdwarf-dev
回答by LaPingvino
Just for future reference, I ran into this problem on my debian machine, and it turned out that in my case
仅供参考,我在我的 debian 机器上遇到了这个问题,结果证明在我的情况下
$ apt-file find /usr/include/sys/types.h
libc6-dev-i386: /usr/include/sys/types.h
libc6-dev-i386 is the package I seemingly need to install
libc6-dev-i386 是我貌似需要安装的包