设为首页 加入收藏

TOP

LDD3在Ubuntu下编译模块
2014-11-24 03:03:28 来源: 作者: 【 】 浏览:2
Tags:LDD3 Ubuntu 编译 模块

1、提示scripts/Makefile.build:46:*** CFLAGS was changed in "/home/chenfang/scull/Makefile",Fix it use EXTRA_CFLAGS.Stop.:


由于LDD3使用的是2.6.10内核,很多东西已经发生了变化,这里提示我们修改Makefile中的CFLAGS,用EXTRA_CFLAGS代替,照它说的做就可以。


2、提示找不到文件linux/config.h: 在2.6.19开始的内核中删除了config.h文件,因此只要在mian.c中注释掉#include即可。


3、提示access.c中存在:dereferencing pointer to incomplete type 错误: 在 源码中发现只能是current存在错误,current应该是一个task_struct类型的全局变量,查找task_struct存在于 linux/sched.h中,因此在access.c中加入#include,重新make即可。


顺便看下current这个全局变量是在哪里定义的: 在source ininsight中查找得到的current类似于以下的定义: static inline struct task_struct *get_current(void) __attribute_const__; static inline struct task_struct *get_current(void) { return current_thread_info()->task; } #define current (get_current()) 可 见,current其实是一个“伪全局变量”,是函数get_current()的宏定义。


/home/dengwei/eclipse_workspace/scull/access.c:108: error: ‘struct task_struct’ has no member named ‘uid’


/home/dengwei/eclipse_workspace/scull/access.c:109: error: ‘struct task_struct’ has no member named ‘euid’


/home/dengwei/eclipse_workspace/scull/access.c:116: error: ‘struct task_struct’ has no member named ‘uid’ /home/dengwei/eclipse_workspace/scull/access.c: In function ‘scull_w_available’:


/home/dengwei/eclipse_workspace/scull/access.c:167: error: ‘struct task_struct’ has no member named ‘uid’


/home/dengwei/eclipse_workspace/scull/access.c:168: error: ‘struct task_struct’ has no member named ‘euid’


/home/dengwei/eclipse_workspace/scull/access.c: In function ‘scull_w_open’:


/home/dengwei/eclipse_workspace/scull/access.c:186: error: ‘struct task_struct’ has no member named ‘uid’ 原因: 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 make success


结果: root@dw:/home/dengwei/eclipse_workspace/scull# ls access.c main.o Module.symvers scull.init scull.mod.o access.o Makefile pipe.c scull.ko scull.o _desktop.ini Module.markers pipe.o scull_load scull_unload main.c modules.order scull.h scull.mod.c root@dw:/home/dengwei/eclipse_workspace/scull# insmod scull.ko 按照上面提示,就可以顺利编译成ko文件,其中include/linux在我的Linux中绝对路径名是 /usr/src/linux-headers-2.6.32-21/include/linux


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Linux下一个检查跑批是否成功的Sh.. 下一篇Linphone编译 : Linux 下 无Vide..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Announcing October (2025-12-24 15:18:16)
·MySQL有什么推荐的学 (2025-12-24 15:18:13)
·到底应该用MySQL还是 (2025-12-24 15:18:11)
·进入Linux世界大门的 (2025-12-24 14:51:47)
·Download Linux | Li (2025-12-24 14:51:44)