2012-05-31 52 views
0

我正在linux下构建一个示例内核模块。模块源“离开内核树”。我有git的内核源码树。但是配置内核需要时间。所以在这一刻,我只是试图根据我的发行版提供的内核头来构建模块。构建“脱离源代码树”内核模块

我的Makefile:

KVERSION=$(shell uname -r) 
    PWD := $(shell pwd) 
    all: 
      make -C /lib/modules/$(KVERSION)/build/ M=$(PWD) modules 
    clean: 
      make -C /lib/modules/$(KVERSION)/build M=$(PWD) clean 


    $(info Building with KERNELRELEASE = ${KERNELRELEASE}) 
    obj-m := hello.o 

但要与报告停止,我无法找到等,这意味着它找不到头。

但文件是否有:

$ls /lib/modules/$(uname -r)/build 
$arch block crypto drivers firmware fs include init ipc kernel lib Makefile    Makefile.common mm Module.symvers net samples scripts security sound System.map tools usr virt 

我想它是一个很重要的问题。但是我仍然无法找到解决方案。

在此先感谢。

编辑:错误:

Building with KERNELRELEASE = 
make -C /lib/modules/2.6.32-220.el6.x86_64/build/ M=/usr/local/src/kernel_mods 
make[1]: Entering directory `/usr/src/kernels/2.6.32-220.el6.x86_64' 
Building with KERNELRELEASE = 2.6.32-220.el6.x86_64 
    LD  /usr/local/src/kernel_mods/built-in.o 
    CC [M] /usr/local/src/kernel_mods/hello.o 
/usr/local/src/kernel_mods/hello.c:2:27: error: linux/modules.h: No such file or directory 
/usr/local/src/kernel_mods/hello.c:21: error: expected declaration specifiers or â...â before string constant 
/usr/local/src/kernel_mods/hello.c:21: warning: data definition has no type or storage class 
/usr/local/src/kernel_mods/hello.c:21: warning: type defaults to âintâ in declaration of âMODULE_LICENSEâ 
/usr/local/src/kernel_mods/hello.c:21: warning: function declaration isnât a prototype 
/usr/local/src/kernel_mods/hello.c:22: error: expected declaration specifiers or â...â before string constant 
/usr/local/src/kernel_mods/hello.c:22: warning: data definition has no type or storage class 
/usr/local/src/kernel_mods/hello.c:22: warning: type defaults to âintâ in declaration of âMODULE_AUTHORâ 
/usr/local/src/kernel_mods/hello.c:22: warning: function declaration isnât a prototype 
/usr/local/src/kernel_mods/hello.c:23: error: expected declaration specifiers or â...â before string constant 
/usr/local/src/kernel_mods/hello.c:23: warning: data definition has no type or storage class 
/usr/local/src/kernel_mods/hello.c:23: warning: type defaults to âintâ in declaration of âMODULE_DESCRIPTIONâ 
/usr/local/src/kernel_mods/hello.c:23: warning: function declaration isnât a prototype 
make[2]: *** [/usr/local/src/kernel_mods/hello.o] Error 1 
make[1]: *** [_module_/usr/local/src/kernel_mods] Error 2 
make[1]: Leaving directory `/usr/src/kernels/2.6.32-220.el6.x86_64' 
make: *** [all] Error 2 
+0

是否可以从制作添加确切的错误信息? –

回答

3

我想你的意思做

#include <linux/module.h> 

而不是

#include <linux/modules.h> 
+0

我知道我在做一件很愚蠢的事情。谢谢。 – Aftnix

相关问题