我正在尝试编译一个简单的测试内核模块,但是gcc给我发了这个错误:
fatal error: linux/modversions.h: file or directory not found
但在 / usr / src确实包含linux源的符号链接
ls -l /usr/scr/
drwxr-xr-x 2 root root 4096 apr 26 13:31 fglrx-14.9+ga14.201
lrwxrwxrwx 1 root root 39 lug 11 13:36 linux -> /home/nhoya/Scaricati/linux-source-3.16
drwxr-xr-x 2 root root 4096 lug 10 17:49 linux-config-3.16
drwxr-xr-x 4 root root 4096 lug 10 15:57 linux-headers-3.2.0-4-amd64
drwxr-xr-x 4 root root 4096 apr 26 22:24 linux-headers-3.2.0-4-common
lrwxrwxrwx 1 root root 23 giu 24 2012 linux-kbuild-3.2 -> ../lib/linux-kbuild-3.2
-rw-r--r-- 1 root root 81869308 mag 24 20:24 linux-source-3.16.tar.xz
drwxr-xr-x 12 root root 4096 giu 7 23:31 virtualbox-4.3.18
和
locate modversions.h
/home/nhoya/Scaricati/linux-source-3.16/include/config/modversions.h
/usr/src/linux-headers-3.2.0-4-amd64/include/config/modversions.h
所以,我真的不明白这个问题......这是模块源
#define __KERNEL__
#define MODULE
#include <linux/modversions.h>
#include <linux/module.h>
#include <linux/tty.h>
int init_mod()
{
console_print("test\n");
return 0;
}
void cleanup_mod()
{
console_print("fine test\n");
}