日期:2014-05-16  浏览次数:20597 次

ARM内核模块编译
下面是我用的原码!  

  1 #include <linux/module.h>
  2 
  3 int int_module(void){
  4 printk(" <1> hello world!\n");
  5 return 0;
  6 }
  7 
  8 void cleanup_module(void){
  9 printk(" <1> goodbye!\n");
 10 }
 
我用来编译的命令arm-linux-gcc -o hello.o _D__KERNEL__ -DMODULE -I /home/linux-2.6.38/include -c hello.c

错误为
arm-linux-gcc: _D__KERNEL__: No such file or directory
In file included from /home/linux-2.6.38/include/linux/list.h:4:0,
  from /home/linux-2.6.38/include/linux/module.h:9,
  from hello.c:1:
/home/linux-2.6.38/include/linux/types.h:13:2: warning: #warning "Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders"
In file included from /home/linux-2.6.38/include/linux/list.h:7:0,
  from /home/linux-2.6.38/include/linux/module.h:9,
  from hello.c:1:
/home/linux-2.6.38/include/linux/prefetch.h:14:27: fatal error: asm/processor.h: No such file or directory
compilation terminated.

我是新手,请高人指点啊,


------解决方案--------------------
找LDD3上的makefile试试
------解决方案--------------------
_D__KERNEL__ ==> -D__KERNEL__