LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1296|回复: 3

编译驱动出错 求帮助

[复制链接]
发表于 2008-5-2 21:10:28 | 显示全部楼层 |阅读模式
我程序:
#include <linux/init.h>
#include <linux/module.h>

static int hello_init(void)
{
        printk(KERN_ALERT "HELLO WORD\n");
        return 0;
}

static int hello_exit(void)
{
        printk(KERN_ALERT "good bye!\n");
        return 0;
}

module_init(hello_init);
module_exit(hello_exit);

我的makefile:
obj-m+=hello.o


[root@localhost temp]# make -C /usr/src/linux-2.4.20-8 SUBDIRS=`pwd` modules
make: Entering directory `/usr/src/linux-2.4.20-8'
make -r -f tmp_include_depends all
make[1]: Entering directory `/usr/src/linux-2.4.20-8'
make[1]: Circular /usr/src/linux-2.4.20-8/include/asm/smplock.h <- /usr/src/linu
x-2.4.20-8/include/linux/interrupt.h dependency dropped.
make[1]: Circular /usr/src/linux-2.4.20-8/include/linux/netfilter_ipv4/ip_conntr
ack.h <- /usr/src/linux-2.4.20-8/include/linux/netfilter_ipv4/ip_conntrack_helpe
r.h dependency dropped.
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/usr/src/linux-2.4.20-8'
make -C  /root/temp CFLAGS="-D__KERNEL__ -I/usr/src/linux-2.4.20-8/include -Wall
-Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-
frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686 -DMODULE" MAKING_MO
DULES=1 modules
make[1]: Entering directory `/root/temp'
make[1]: *** No rule to make target `modules'.  Stop.
make[1]: Leaving directory `/root/temp'
make: *** [_mod_/root/temp] Error 2
make: Leaving directory `/usr/src/linux-2.4.20-8'
发表于 2008-5-7 19:40:20 | 显示全部楼层
make[1]: *** No rule to make target `modules'. Stop.

没有规则生成目标文件

hello.o :hello.c
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-5-11 20:54:58 | 显示全部楼层
谢谢您, 我后来仔细的阅读了Linux 的makefile,  发现 2.4 和2.6 是不同的

并且把makefile 该成
obj-m := hello.o


include $(TOPDIR)/Rules.make

也是可以解决的
回复 支持 反对

使用道具 举报

 楼主| 发表于 2008-5-11 20:55:38 | 显示全部楼层
确实是没有依赖关系造成的

呵呵
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表