我正在尝试编译模块,但是得到了这个错误。
fatal error: sys/types.h: No such file or directory
compilation terminated.这是我的模块文件头
#include <linux/init.h>           // Macros used to mark up functions e.g. __init __exit
#include <linux/module.h>         // Core header for loading LKMs into the kernel
#include <linux/device.h>         // Header to support the kernel Driver Model
#include <linux/kernel.h>         // Contains types, macros, functions for the kernel
#include <linux/fs.h>             // Header for the Linux file system support
#include <asm/uaccess.h>          // Required for the copy to user function
#include <sys/types.h>还有我的Makefile
obj-m = test.o
all:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
    make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean我试着搜索这个文件
 find /usr/include -name types.h以下是结果
/usr/include/sys/types.h
/usr/include/libr/sdb/types.h
/usr/include/rpc/types.h
/usr/include/i386-linux-gnu/sys/types.h
/usr/include/i386-linux-gnu/asm/types.h
/usr/include/i386-linux-gnu/bits/types.h
/usr/include/linux/iio/types.h
/usr/include/linux/types.h
/usr/include/x86_64-linux-gnu/sys/types.h
/usr/include/x86_64-linux-gnu/asm/types.h
/usr/include/x86_64-linux-gnu/bits/types.h
/usr/include/asm-generic/types.h
/usr/include/c++/5/parallel/types.h我试着把它设置为#include "/usr/include/sys/types.h"
但得到了跟随错误
/usr/include/sys/types.h:25:22: fatal error: features.h: No such file or directory
compilation terminated.我使用的是Kali Linux(Debian) AMD64平台
Linux kali 4.5.0-kali1-amd64 #1 SMP Debian 4.5.5-1kali1 (2016-06-06) x86_64 GNU/Linux怎么了?谢谢
解决了
对不起,这是我的错,我在类型上做了一个错误,并试图包含sys/types.h文件,但在我的情况下,并非所有类型都是在/usr/src/linux-headers-4.5.0-kali1-common/include/linux/types.h中声明的。谢谢大家。
发布于 2016-06-12 16:12:13
对不起,这是我的错,我在类型上做了一个错误,并试图包含sys/ypes.h文件,但在我的例子中,并非所有类型都是在/usr/src/linux-headers-4.5.0-kali1-common/include/linux/types.h中声明的。谢谢大家。
发布于 2018-04-28 03:47:19
我在Linux上也有类似的错误。
致命错误:sys/ file .h:没有这样的文件或目录
修正了以下问题:
sudo apt install libc6-dev发布于 2016-06-12 06:46:15
我建议查看gcc是否正在使用命令查找文件所在的目录中的头文件:
`gcc -print-prog-name=cc1` -v      # for chttps://stackoverflow.com/questions/37771339
复制相似问题