|
|
系统环境:rh9.0 kernel 2.4.20-8 @ WinXp+virtual Pc
hello.c
#include <linux/kernel.h> /* We're doing kernel work */
#include <linux/module.h> /* Specifically, a module */
#if CONFIG_MODVERSIONS= =1
#define MODVERSIONS
#include <linux/modversions.h>
#endif
int init_module()
{
printk("Hello, world - this is the kernel speaking\n");
return 0;
}
void cleanup_module()
{
printk("Short is the life of a kernel module\n");
}
Makefile:
CC=gcc
MODCFLAGS := -Wall -DMODULE -D__KERNEL__ -DLINUX
hello.o: hello.c /usr/include/linux/version.h
$(CC) $(MODCFLAGS) -c hello.c
echo insmod hello.o to turn it on
echo rmmod hello to turn if off
echo
echo X and kernel programming do not mix.
echo Do the insmod and rmmod from outside
完全按照例子敲的,make的时候也没有什么错误提示,
不过在insmod时提示:couldn't find the kernel version the module compiled for .
这是怎么回事呢? |
|