helloworld 驱动程序编译的问题?

失落的羊 失落的羊 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
一个简单的驱动程序例子,怎么编译都不行,请指教。源代码和makefile 如下:
我的机器: winxp +vmware






/*
* $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $
*/
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE( "Dual BSD/GPL ");

static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n ");
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n ");
}

module_init(hello_init);
module_exit(hello_exit);



makefile:

ifeq ($(KERNELRELEASE),)
KDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
modules:
$(MAKE) -C $(KDIR) M=$(PWD) modules
modules_install:
$(MAKE) -C $(KDIR) M=$(PWD) modules_install
clean:
rm -rf *.ko *.o *.mod.c
.PHONY:modules modules_install clean
else
obj-m := hello.o
endif



出错信息如下:

make -C /lib/modules/2.6.21-1.3194.fc7/build M=/tonny/test/chapter12/hello modules
make[1]: Entering directory `/usr/src/kernels/2.6.21-1.3194.fc7-i686'
scripts/Makefile.build:17: /tonny/test/chapter12/hello/Makefile: No such file or directory
make[2]: *** No rule to make target `/tonny/test/chapter12/hello/Makefile'. Stop.
make[1]: *** [_module_/tonny/test/chapter12/hello] Error 2
make[1]: Leaving directory `/usr/src/kernels/2.6.21-1.3194.fc7-i686'
make: *** [modules] Error 2

...全文

相关推荐

评论 12
收藏 已收藏
分享
返回顶部
失落的羊
Linux_Kernel 4,469 成员 17,458 内容