在哪里sys /类型。h位置?

时间:2022-05-01 06:26:16

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.

我刚刚发现 和< stdio。h> header位于Ubuntu服务器的/usr/include文件夹中,但我找不到sys/types.h。 。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?

这是真的吗?文件在哪里?

6 个解决方案

#1


45  

My Debian box (and hopefully Ubuntu haven't butchered it too much in their zeal) has it in /usr/include/sys/types.h.

我的Debian box(希望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 the echo statement.

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

The final grep just strips out the unimportant lines.

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

#2


14  

The file sys/types.h is located at the /usr/include/sys/types.h

文件系统/类型。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

#3


4  

If you have locate command available you can simply use 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.

这是最快、最简单的方法。

#4


2  

On Linux, types.h should be in /usr/include/sys/types.h.

在Linux上,类型。h应该在/usr/include/sys/types.h中

#5


2  

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

#6


0  

In my Slackware I needed install glibc to solve this problem.

我需要安装glibc来解决这个问题。

#1


45  

My Debian box (and hopefully Ubuntu haven't butchered it too much in their zeal) has it in /usr/include/sys/types.h.

我的Debian box(希望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 the echo statement.

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

The final grep just strips out the unimportant lines.

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

#2


14  

The file sys/types.h is located at the /usr/include/sys/types.h

文件系统/类型。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

#3


4  

If you have locate command available you can simply use 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.

这是最快、最简单的方法。

#4


2  

On Linux, types.h should be in /usr/include/sys/types.h.

在Linux上,类型。h应该在/usr/include/sys/types.h中

#5


2  

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

#6


0  

In my Slackware I needed install glibc to solve this problem.

我需要安装glibc来解决这个问题。