简体   繁体   English

"sys\/types.h 位于何处?"

[英]Where is sys/types.h located?

I just found out that the <stdlib.h><\/code> and <stdio.h><\/code> headers are located in the \/usr\/include<\/code> folder in Ubuntu server, but I don't find sys\/types.h<\/code> .我刚刚发现<stdlib.h><\/code>和<stdio.h><\/code>标头位于 Ubuntu 服务器的\/usr\/include<\/code>文件夹中,但我没有找到sys\/types.h<\/code> 。

And I start to suspect the compiler won't actually use the header file in the \/usr\/include<\/code> folder.我开始怀疑编译器实际上不会使用\/usr\/include<\/code>文件夹中的头文件。

Is this true, and where is the file located?这是真的吗,文件在哪里?

"

My Debian box (and hopefully Ubuntu haven't butchered it too much 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). 我想成像一个服务器盒用作服务器,如果编译器和一堆其他东西不是默认安装的一部分,它不会让我感到惊讶(但它会有很多服务器的东西,如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 gcc command line stops after the pre-processing phase ( -E ), forces the file to be treated as C source code ( -xc ) and retrieves the program from standard input ( - ), in this case from the echo statement. 旁白: gcc命令行在预处理阶段( -E )之后停止,强制将文件视为C源代码( -xc )并从标准输入( - )检索程序,在这种情况下从echo语句中检索。

The final grep just strips out the unimportant lines. 最后的grep只是剥掉了不重要的线条。

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

Fix by using the following code: 使用以下代码进行修复

sudo apt-get install build-essential flex libelf-dev libc6-dev-amd64 binutils-dev libdwarf-dev

If you have locate command available you can simply use 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. 这是最快捷,最简单的方法。

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是我看似需要安装的软件包

在Linux上, types.h应该在/usr/include/sys/types.h

在我的Slackware中,我需要安装glibc来解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM