当前位置: 技术问答>linux和unix
ARM内核模块编译
来源: 互联网 发布时间:2017-01-23
本文导语: 下面是我用的原码! 1 #include 2 3 int int_module(void){ 4 printk(" hello world!n"); 5 return 0; 6 } 7 8 void cleanup_module(void){ 9 printk(" goodbye!n"); 10 } ...
下面是我用的原码!
1 #include
2
3 int int_module(void){
4 printk(" hello world!n");
5 return 0;
6 }
7
8 void cleanup_module(void){
9 printk(" 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.
我是新手,请高人指点啊,
1 #include
2
3 int int_module(void){
4 printk(" hello world!n");
5 return 0;
6 }
7
8 void cleanup_module(void){
9 printk(" 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.
我是新手,请高人指点啊,
|
_D__KERNEL__ ==> -D__KERNEL__
|
找LDD3上的makefile试试