打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
LDD3 第三章 scull 编译错误改正

由于linux内核版本的升级,往往会让能在老版本内核上编译通过的驱动程序移植到新版本内核中出现各种编译和链接错误,这里就将我遇到的一些问题做个整理,让后续开发更流畅^_^!

当前内核版本为2.6.38-15

1.make[1]: Entering directory `/usr/src/linux-***' scripts/Makefile.build:49: *** CFLAGS was changed in "***/Makefile". Fix it to use ***.  Stop.

原因:与Makefile.build中的CFLAGS冲突

建议:删除CFLAGS或者将CFLAGS重命名


2. fatal error: linux/config.h: No such file or directory

原因:linux-2.6.20起,linux/config.h被移除了

建议:可以添加如下代码

#if(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18))

#if(LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,33))

#include <generated/autoconf.h>

#else

#include <linux/autoconf.h>

#endif

#else

#include <linux/config.h>

#endif


3. error: unknown field 'ioctl’ specified in initializer

原因:linux-2.6.26起,file_operations修改了,移除了ioctl,添加了如下两个接口

long(*unlocked_ioctl)(structfile *, unsignedint,unsignedlong);

long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
建议:视程序使用情况,把.ioctl修改成为.unlocked_ioctl或者compat_ioctl


4 error: implicit declaration of function 'init_MUTEX’

原因:linux-2.6.25起,移除init_MUTEX,init_MUTEX_LOCKED宏定义

建议:添加如下代码

#include <linux/semaphore.h>

#define init_MUTEX(a) sema_init(a,1)

#define init_MUTEX_LOCKED(a) sema_init(a,0)


5. error: 'TASK_INTERRUPTIBLE’ undeclared (first use in this function)

原因:linux-2.6.19起,TASK_INTERRUPTIBLE的定义被移动到linux/sched.h

建议:添加头文件 linux/sched.h


6. error: 'SPIN_LOCK_UNLOCKED’ undeclared here 

原因:新版本内核中,SPIN_LOCK_UNLOCKED被移除

建议:使用DEFINE_SPINLOCK(lock)宏来替代


7. error: 'struct task_struct’ has no member named 'uid’/ 'euid’

原因:linux-2.6.31起,struct task_struct定义在include/linux/sched.h中,原来task_struct结构体定义有所改动,将uid和euid等挪到 cred中,见include/linux/sched.h和              include/linux/cred.h

建议:只需要将报error的代码做如下修改

current->uid 修改为 current->cred->uid

current->euid 修改为 current->cred->euid

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
如何修改ldd源码,才能通过编译
内核2.6.38更新2.6.35的地方
【原创】Linux select/poll机制原理分析
linux GPIO驱动
linux下vlan功能实现
Linux下AM335X的GPIO控制
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服