- 论坛徽章:
- 0
|
这是一个简单字符设备驱动的makefile,源码拿人家的,应该没错,makefile如下:- ifneq ($(KERNELRELEASE),)
- obj-m:=memdev.o
- else
- KERNELDIR:=/lib/modules/$(shell uname -r)/build #内核目录
- PWD:=$(shell pwd) #当前目录
- default:
- make -C $(KERNELDIR) M=$(PWD) modules
- clean:
- rm -rf *.o *mod.c *.mo
复制代码 错误信息如下:- noah@ubuntu:~/Desktop$ make
- make -C /lib/modules/2.6.35-22-generic/build M=/home/noah/Desktop modules
- make[1]: Entering directory `/usr/src/linux-headers-2.6.35-22-generic'
- CC [M] /home/noah/Desktop/memdev.o
- /home/noah/Desktop/memdev.c:15: warning: type defaults to ‘int’ in declaration of ‘mem_major’
- /home/noah/Desktop/memdev.c: In function ‘mem_read’:
- /home/noah/Desktop/memdev.c:71: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
- /home/noah/Desktop/memdev.c: In function ‘mem_write’:
- /home/noah/Desktop/memdev.c:99: warning: format ‘%d’ expects type ‘int’, but argument 3 has type ‘long unsigned int’
- /home/noah/Desktop/memdev.c: In function ‘memdev_init’:
- /home/noah/Desktop/memdev.c:174: error: implicit declaration of function ‘kmalloc’
- /home/noah/Desktop/memdev.c:174: warning: assignment makes pointer from integer without a cast
- /home/noah/Desktop/memdev.c:186: warning: assignment makes pointer from integer without a cast
- /home/noah/Desktop/memdev.c: In function ‘memdev_exit’:
- /home/noah/Desktop/memdev.c:202: error: implicit declaration of function ‘kfree’
- make[2]: *** [/home/noah/Desktop/memdev.o] Error 1
- make[1]: *** [_module_/home/noah/Desktop] Error 2
- make[1]: Leaving directory `/usr/src/linux-headers-2.6.35-22-generic'
- make: *** [default] Error 2
复制代码 希望大牛们帮我解决一下问题:
1、之所以出错是不是因为找不到kfree和kmalloc的头文件,如果是mm.h的话,我在/usr/src/linux-headers-2.6.35-22-generic/include/linux中能找到,可接下来又要干嘛?
2、能不能详详细细的解释这个makefile的所有执行过程,一直都搞不清楚到底是怎么样编译的,我也在网上搜过和根据控制台输出的信息分析过,可还是不懂,如:obj-m:=memdev.o为啥没用过?$(KERNELRELEASE)是什么变量?make -C $(KERNELDIR) M=$(PWD) modules有M=这个选项吗?我驱动的源码文件是memdev.c,为何至始至终都没出现过?等等,希望大牛解释的详细一点。 |
|