- 论坛徽章:
- 0
|
读了davidxueer Linux内核编程(前言)zt
照猫画虎的写了程序和Makefile
#include <linux/kernel.h>;
#include <linux/module.h>;
#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 后
intmod hello.o
系统给出如下错误:
hello.o: kernel-module version mismatch
hello.o was compiled for kernel version 2.4.9-9
while this kernel is version 2.4.18-3.
我的系统
Linux version 2.4.18-3 (gcc version 2.96 20000731 (Red Hat Linux 7.3 2.96-110))
what should i do? |
|