问一下<linux/init.h><linux/module.h>这两个文件从哪里来的??我在/usr/include/linux下的确没有这两个文件,我一个月前也是这样安装就能编译这个hello.c
linux-headers-2.6.15.5-kdb_2.6.15.5-kdb-10.00.Custom_i386.deb
linux-image-2.6.15.5-kdb_2.6.15.5-kdb-10.00.Custom_i386.deb
想要这两个包的 可以加我qq 77519697
我自己编译的内核,安装上面两个包,提示
hello.c
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
//printk(KERN_EMERG "Hello World enter!\n");
printk(KERN_ALERT "Hello World enter!\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Hello world exit!\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile
obj-m := hello.o
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD ?= $(shell pwd)
defalult:
make -C ${KERNELDIR} M=${PWD} modules
install:
insmod hello.ko
uninstall:
rmmod hello.ko
clear:
make -C ${KERNELDIR} M=${PWD} clean
root@ubuntu:/home/zrt/xp# make hello
cc hello.c -o hello
hello.c:1:24: error: linux/init.h: No such file or directory
hello.c:2:26: error: linux/module.h: No such file or directory
hello.c:4: error: expected declaration specifiers or 鈥?..鈥?before string constant
hello.c:4: warning: data definition has no type or storage class
hello.c: In function 鈥榟ello_init鈥?
hello.c:9: error: 鈥楰ERN_ALERT鈥?undeclared (first use in this function)
hello.c:9: error: (Each undeclared identifier is reported only once
hello.c:9: error: for each function it appears in.)
hello.c:9: error: expected 鈥?鈥?before string constant
hello.c: In function 鈥榟ello_exit鈥?
hello.c:15: error: 鈥楰ERN_ALERT鈥?undeclared (first use in this function)
hello.c:15: error: expected 鈥?鈥?before string constant
hello.c: At top level:
hello.c:18: warning: data definition has no type or storage class
hello.c:18: warning: parameter names (without types) in function declaration
hello.c:19: warning: data definition has no type or storage class
hello.c:19: warning: parameter names (without types) in function declaration
make: *** [hello] Error 1
我自己编译的内核和内核头文件,安装后无法编写程序,提示error: linux/init.h: No such file
-
- 帖子: 2
- 注册时间: 2010-12-15 20:47