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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 14:01:24  来源:igfitidea点击:

Where is sys/types.h located?

clinuxubuntu

提问by mko

I just found out that the <stdlib.h>and <stdio.h>headers are located in the /usr/includefolder in Ubuntu server, but I don't find sys/types.h.

我刚刚发现<stdlib.h><stdio.h>标头位于/usr/includeUbuntu 服务器的文件夹中,但我没有找到sys/types.h.

And I start to suspect the compiler won't actually use the header file in the /usr/includefolder.

我开始怀疑编译器实际上不会使用文件/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 ftpdor Apacheand so on).

但是,请记住,甚至可能不会安装开发内容我会想象一个服务器盒被用作服务器,如果编译器和一堆其他东西不是默认安装的一部分,我不会感到惊讶(但它会有很多服务器东西,比如ftpdApache和很快)。

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 gcccommand 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 the echostatement.

旁白:该gcc命令行在预处理阶段 ( -E)之后停止,强制将文件视为 C 源代码 ( -x c) 并从标准输入 ( -)检索程序,在本例中为echo语句。

The final grepjust strips out the unimportant lines.

最后grep只是去掉不重要的行。

回答by wallyk

On Linux, types.hshould 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.his 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 是我貌似需要安装的包