LDD3中scull在新内核上编译中的各种error处理
来源:互联网 发布:ubuntu删除桌面图标 编辑:程序博客网 时间:2024/05/14 08:32
LDD3中的第一个例程就是scull,但是在新内核上编译的过程那叫一个坎坷。。。
在此做出总结,希望可以帮到同路人。。。
一、错误:
error: linux/config.h: No such file or directory
解决:
从linux-2.6.20起,config.h就已经被移除了.
在main.c中,
将#include <linux/config.h>
改为:
#include <linux/version.h>#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)) #include <linux/config.h>#endif
二、错误:
/ldd3_examples/scull/main.c:32:46: fatal error: asm/system.h: No such file or directory
解决:
在main.c中,
将#include <asm/system.h> /* cli(), *_flags */
改为:
#if LINUX_VERSION_CODE > KERNEL_VERSION(3,3,0) #include <asm/switch_to.h>#else #include <asm/system.h> /* cli(), *_flags */#endif
在目录:/usr/src/linux-headers-3.11.0-15/include下没有asm,只有asm-generic,执行ln -s asm-generic asm
可以解决。
三、错误:
error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
解决:
在新版本的linux内核中,init_mutex已经被废除了,新版本使用sema_init函数。需要在main.c中包含头文件#include<linux/semaphore.h>
将init_MUTEX(&scull_devices[i].sem);
改为:sema_init(&scull_devices[i].sem,1);
四、错误:
error: unknown field ‘ioctl’ specified in initializer
解决:
原因是:在2.6.36内核上file_operations发生了重大的改变:
原先的
int (ioctl)(struct inode, struct file*, unsigned int, unsigned long);
被改为了
long (unlocked_ioctl) (struct file , unsigned int, unsigned long);
long (compat_ioctl) (struct file , unsigned int, unsigned long);因而在实际驱动中,我们需要将原先的写的ioctl函数头给改成下面的unlocked_ioctl,在file_operations结构体的填充中也是一样。
五、错误:
/home/jassion/work/book/ldd3_examples/scull/pipe.c: In function ‘scull_p_read’:
/home/jassion/work/book/ldd3_examples/scull/pipe.c:131:7: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/jassion/work/book/ldd3_examples/scull/pipe.c:131:7: note: each undeclared identifier is reported only once for each function it appears in
/home/jassion/work/book/ldd3_examples/scull/pipe.c:131:3: error: implicit declaration of function ‘signal_pending’ [-Werror=implicit-function-declaration]
/home/jassion/work/book/ldd3_examples/scull/pipe.c:131:3: error: implicit declaration of function ‘schedule’ [-Werror=implicit-function-declaration]
/home/jassion/work/book/ldd3_examples/scull/pipe.c: In function ‘scull_getwritespace’:
/home/jassion/work/book/ldd3_examples/scull/pipe.c:168:38: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/jassion/work/book/ldd3_examples/scull/pipe.c: In function ‘scull_p_write’:
/home/jassion/work/book/ldd3_examples/scull/pipe.c:219:2: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
/home/jassion/work/book/ldd3_examples/scull/pipe.c:223:34: error: ‘SIGIO’ undeclared (first use in this function)
/home/jassion/work/book/ldd3_examples/scull/pipe.c:223:41: error: ‘POLL_IN’ undeclared (first use in this function)
解决:
头文件变动原因,在pipe.c中添加
#include <linux/sched.h>
六、错误:
/home/jassion/work/book/ldd3_examples/scull/pipe.c:321:2: error: unknown field ‘ioctl’ specified in initializer
解决:
在pipe.c中,
将.ioctl = scull_ioctl,
改为.unlocked_ioctl = scull_ioctl,
七、错误:
/home/jassion/work/book/ldd3_examples/scull/pipe.c: In function ‘scull_p_init’:
/home/jassion/work/book/ldd3_examples/scull/pipe.c:367:3: error: implicit declaration of function ‘init_MUTEX’ [-Werror=implicit-function-declaration]
解决:
在pipe.c中,
将init_MUTEX(&scull_p_devices[i].sem);
改为:sema_init(&scull_p_devices[i].sem,1);
八、错误:
access.c中的一系列错误
1、/home/jassion/work/book/ldd3_examples/scull/access.c:98:34: error: ‘SPIN_LOCK_UNLOCKED’ undeclared here (not in a function)
解决:原因,SPIN_LOCK_UNLOCKED在新内核中被弃用
在access.c中添加头文件:
#include <linux/spinlock_types.h>
修改定义 static spinlock_t scull_u_lock = SPIN_LOCK_UNLOCKED;
为:static DEFINE_SPINLOCK(scull_u_lock);
2、/home/jassion/work/book/ldd3_examples/scull/access.c:179:3: error: implicit declaration of function ‘signal_pending’ [-Werror=implicit-function-declaration]
/home/jassion/work/book/ldd3_examples/scull/access.c:179:3: error: implicit declaration of function ‘schedule’ [-Werror=implicit-function-declaration]。。。。。。。
解决:
在access.c中添加头文件:
#include <linux/sched.h>
3、/home/jassion/work/book/ldd3_examples/scull/access.c: In function ‘scull_u_open’:
/home/jassion/work/book/ldd3_examples/scull/access.c:108:29: error: ‘struct task_struct’ has no member named ‘uid’
/home/jassion/work/book/ldd3_examples/scull/access.c:109:29: error: ‘struct task_struct’ has no member named ‘euid’
/home/jassion/work/book/ldd3_examples/scull/access.c:116:26: error: ‘struct task_struct’ has no member named ‘uid’
。。。。。。
解决:原因:新的struct task_struct 定义有变化,uid和euid在cred结构体中。
办法:加头文件#include <linux/cred.h>
,
将 current->uid改为current->cred->uid,
current->euid改为current->cred->euid
其他的问题,参考上面的方法进行处理即可。
编译成功之后的截图:
- LDD3中scull在新内核上编译中的各种error处理
- 在内核3.17.6上编译scull(LDD3)
- (LDD3)Scull在2.6.35-30内核中的编译解决方案
- Scull在2.6.35-30内核中的编译解决方案
- scull 在2.6.32-5内核中的编译解决方案
- LDD3 /scull 驱动实例在linux3.2.0编译实现
- [linux设备驱动程序]scull字符设备驱动编译在新内核编译问题解决方案
- 在Ubuntu 9.04 内核2.6.32.2 上编译Linux driver edit3 例子详解scull
- ldd3 读书笔记 —— scull 1 编译,解决内核更新引起的错误
- LDD3学习笔记--scull的编译
- ubuntu 1204 kernel 3.2编译ldd3 scull
- 编译LDD3的scull驱动问题总结
- LDD3学习笔记scull编译错误解决
- LDD3在Ubuntu下编译 scull例子时遇到的一些问题
- ldd3 scull代码理解
- LDD3 scull pipe 模块
- LDD3中scull字符设备源代码完全解析(一)
- ldd3第三章 scull实验中常见错误
- Hibernate配置详解
- 省赛
- android 事件冲突问题
- Linux下静默安装oracle11.2.0.4软件
- 银行运维点滴-----CRM系统出报表
- LDD3中scull在新内核上编译中的各种error处理
- 万能的多文件上传例子
- Cocos2d-Lua之赋值
- 保留小数位后16位,4舍5入
- 第十三周项目:动物怎么叫
- ViewPager小圆点无限轮播
- Huffman编码之文件的解/压缩
- 整数基本定理及应用
- Scalaz(45)- concurrency :Task-函数式多线程编程核心配件