Linux 内核模块编译(hello.c) 模块文件hello.c代码 #include <linux/kernel.h> #include <linux/module.h> #ifdef MODEVERSIONS #include <linux/modeversions.h> #endif int init_module() { printk("new module init..."); return 1; } int cleanup_module() { printk("module is removed"); return 0; } makefile文件 CC = gcc MODCFLAGS := -DMODULE -D__KERNEL__ -DLINUX -D__SMP__ hello.o : hello.c <tab>$(CC) $(MODCFLAGS) -c -I/usr/src/linux-2.4.18-3/include -o hello.o hello.c