Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C sys/types.h位于何处?_C_Linux_Ubuntu - Fatal编程技术网

C sys/types.h位于何处?

C sys/types.h位于何处?,c,linux,ubuntu,C,Linux,Ubuntu,我刚刚发现和标题位于Ubuntu服务器的/usr/include文件夹中,但我没有找到sys/types.h 我开始怀疑编译器实际上不会使用/usr/include文件夹中的头文件 这是真的吗?文件在哪里 在Linux上,types.h应该在/usr/include/sys/types.h我的Debian box(希望Ubuntu没有在他们的热情中对它进行过太多的破坏)在/usr/include/sys/types.h中 您的最佳选择是首先执行: find /usr/include -name

我刚刚发现
标题位于Ubuntu服务器的
/usr/include
文件夹中,但我没有找到
sys/types.h

我开始怀疑编译器实际上不会使用
/usr/include
文件夹中的头文件


这是真的吗?文件在哪里

在Linux上,
types.h
应该在
/usr/include/sys/types.h
我的Debian box(希望Ubuntu没有在他们的热情中对它进行过太多的破坏)在
/usr/include/sys/types.h

您的最佳选择是首先执行:

find /usr/include -name types.h
然后:

如果你没有在第一个找到它

但是,请记住,开发人员甚至可能没有安装。我会想象一个服务器盒是用来作为服务器的,如果编译器和其他一些东西不是默认安装的一部分,我也不会感到惊讶(但是它会有很多服务器的东西,比如
ftpd
Apache
等等)

如果编译器将其定位在某个地方,而您不知道它在哪里,则可以使用以下方法:

echo "#include <sys/types.h>" | gcc -E -x c - | grep /types.h
echo“#include”| gcc-E-xc-grep/types.h
找出它的来源

或:

echo“#include”| gcc-E-xc-| grep/stdio.h
你担心的另一个头球

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


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

如果您有可用的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$

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

文件
sys/types.h
位于
/usr/include/sys/types.h

如果您遇到这种致命错误

.../linux/linux_types.h:146:38: fatal error: /usr/include/sys/types.h: No
such file or directory
使用以下代码修复

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

仅供将来参考,我在我的debian机器上遇到了这个问题,结果是在我的情况下

$ apt-file find /usr/include/sys/types.h
libc6-dev-i386: /usr/include/sys/types.h

libc6-dev-i386是我似乎需要安装的软件包

不,头文件必须存在。也许可以查看/usr/local/include.
echo“#include”| gcc-E-xc-| grep类型
以查看它从何处获取它from@H2CO3谢谢你指点out@Mat它是有效的,我发现了,顺便问一下,最后一个参数
-
是用来做什么的?也许这应该在或问一下?哇,答案是什么,我学到了很多,而gcc的
gcc
工作方式,现在我找到了file@yozloy,只是出于兴趣,它在哪里?在Ubuntu12上,我在
/usr/include/linux/types.h
找到了它。如果它只是用于sys/types.h,我认为build essential应该可以做到。在linux mint 16上:sudo获得安装build essential就足够了。
sudo apt-get install build-essential flex libelf-dev libc6-dev-amd64 binutils-dev libdwarf-dev
$ apt-file find /usr/include/sys/types.h
libc6-dev-i386: /usr/include/sys/types.h