xy598646744 发表于 2011-12-09 22:01

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.

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

goldenfort 发表于 2011-12-11 23:40

_D__KERNEL__

好象应该是 -D__KERNEL__

cliffordl 发表于 2013-03-20 11:29

需要一本,内核裁剪的书。求推荐。

rabbit2013 发表于 2013-03-30 23:46

本帖最后由 rabbit2013 于 2013-03-30 23:59 编辑

......nnbnb
页: [1]
查看完整版本: ARM内核模块编译