红联Linux门户
Linux帮助

linux基础

发布时间:2012-07-16 01:14:18来源:红联作者:791143539@qq.co
我现在正在学习linux驱动的编写,这是一个最简单的内核模块helloworld,效果是加载时出现helloworld,卸载时出现goodbye,下面是我的模块文件,makefile,和错误信息,由于我用的是unbuntu的linux,内核版本是2.6.35-22,给出这个heloworld模块的书用的内核版本是2.6.29.4,所以我现在一直编译不过,卡了好几天了,请各位高手帮我一下到底有什么错?
模块文件
#include
#include
static int hello_init()
{
printk(KERN_ALERT "HELLO\n");
return 0;
}
static int hello_exit()
{
printk(KERN_ALERT "GOOD BYE\n");
return 0;
}
module_init(hello_init);
module_exit(hello_exit);

makefile文件

ifeq ($(KERNELRELEASE),)
KD ?= /usr/src/linux-headers-2.6.35-22-gernic
PWD ?= $(shell pwd)
modules:
make -C $(KD) M= $(PWD) modules
modules_install:
make -C $(KD) M= $(PWD) modules_install
clean:
rm *.o
else
obj-m:=hello.o
endif
错误信息为

makefile:4:***command commence before first target.stop
请问这是为什么,我是照着书打上来的啊,而且也没发现什么错……
文章评论

共有 7 条评论

  1. Ubuntu_LW 于 2013-01-21 19:14:05发表:

    看不懂

  2. haiyanmao_linux 于 2013-01-18 10:07:35发表:

    ??始?,貌似也不懂

  3. 于 2013-01-10 14:30:31发表:

    modules:
    make -C $(KD) M= $(PWD) modules
    modules_install:
    make -C $(KD) M= $(PWD) modules_install
    这样

  4. 于 2013-01-10 14:29:13发表:

    在makefile命令下要有加上他tab键

  5. tonylee2012 于 2012-07-16 17:01:45发表:

    刚开始学

  6. 紫梦 于 2012-07-16 12:51:21发表:

    难

  7. Junyi 于 2012-07-16 11:30:18发表:

    这linux基础好不简单