现在的位置: 首页 > 综合 > 正文

Linux 内核模块编译(hello.c)

2013年10月07日 ⁄ 综合 ⁄ 共 394字 ⁄ 字号 评论关闭

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


抱歉!评论已关闭.