怎么样将多个源程序编译成一个驱动?
1.obj-m:= smart_card.o 定义为新名smart_card.o , 说找不到smart_card
#ifneq ($(KERNELRELEASE),)
obj-m:= smart_card.o
module-objs := ncn6001.o smart_driver.o
#else
KDIR = /opt/kernel/utu-linux_for_s3c2440_dm9000_V1.5.8
PWD:=$(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
rm -rf *.o *.ko
#endif
2.定义为两个文件中的一个 , 又不编译连接ncn6001文件 ,说引用那未定义的名称(就是在ncn6001定义的函数 ,在头文件中已经声明那呀)
#ifneq ($(KERNELRELEASE),)
obj-m:= smart_driver.o
module-objs := ncn6001.o smart_driver.o
#else
KDIR = /opt/kernel/utu-linux_for_s3c2440_dm9000_V1.5.8
PWD:=$(shell pwd)
default:
$(MAKE) -C $(KDIR) M=$(PWD) modules
clean:
rm -rf *.o *.ko
#endif
大侠帮忙
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
编译现象 :
[root@localhost drv]# make
make -C /opt/kernel/utu-linux_for_s3c2440_dm9000_V1.5.8 M=/usr/xp_nfs/smart_driver/drv modules
make[1]: Entering directory `/opt/kernel/utu-linux_for_s3c2440_dm9000_V1.5.8'
CC [M] /usr/xp_nfs/smart_driver/drv/smart_driver.o
/usr/xp_nfs/smart_driver/drv/smart_driver.c: In function `T1_Receiv_Send':
/usr/xp_nfs/smart_driver/drv/smart_driver.c:1081: warning: 'ret' might be used uninitialized in this function
Building modules, stage 2.
MODPOST
*** Warning: "Spi_release" [/usr/xp_nfs/smart_driver/drv/smart_driver.ko] undefined!
*** Warning: "Smart_ColdRst" [/usr/xp_nfs/smart_driver/drv/smart_driver.ko] undefined!
*** Warning: "Ncn6001_Init" [/usr/xp_nfs/smart_driver/drv/smart_driver.ko] undefined!
*** Warning: "ncn6001_dat_init" [/usr/xp_nfs/smart_driver/drv/smart_driver.ko] undefined!
*** Warning: "Spi_Init" [/usr/xp_nfs/smart_driver/drv/smart_driver.ko] undefined!
CC /usr/xp_nfs/smart_driver/drv/smart_driver.mod.o
LD [M] /usr/xp_nfs/smart_driver/drv/smart_driver.ko
make[1]: Leaving directory `/opt/kernel/utu-linux_for_s3c2440_dm9000_V1.5.8'
You have new mail in /var/spool/mail/root
加载现象:
[root@utu-linux drv]# insmod smart_driver.ko
Using smart_driver.ko
smart_driver: Unknown symbol Spi_Init
smart_driver: Unknown symbol Ncn6001_Init
smart_driver: Unknown symbol ncn6001_dat_init
smart_driver: Unknown symbol Spi_release
smart_driver: Unknown symbol Smart_ColdRst
这样看来ncn6001根本就没加载和连接进来呀 ?? 原因何在??
你看看LDD3就知道了,上面写得挺详细的。
从你这个现象来看,主要是这些symbol在内核符号表里面没有找到。
有几种可能:
1、头文件没有包含进去或者是函数没有实现;
2、你需要的其他模块导出的函数,但这个模块没有加载进内核。