LinuxDev 板


LINE

环境是Ubuntu 12.04 Linux 3.5.0.42 按照Linux Device Driver 这本书 http://www.makelinux.net/ldd3/?u=chp-2-sect-2 写了简单的helloWorld module 里面写到make指令这样下 make -C ~/kernel-2.6 M=`pwd` modules -c 的参数是kernel的位置 而kernel应该是放在/usr/src/linux-2.6.10 但是我在我的ubuntu里面 /usr/src/资料夹中 只看到下面这些header档 linux-headers-3.2.0-23 linux-headers-3.5.0-37 linux-headers-3.5.0-23 linux-headers-3.5.0-37-generic linux-headers-3.5.0-23-generic linux-headers-3.5.0-42 linux-headers-3.5.0-34 linux-headers-3.5.0-42-generic linux-headers-3.5.0-34-generic linux-source-3.2.0 linux-headers-3.5.0-36 linux-headers-3.5.0-36-generic 我心中有疑惑,但仍尝试编译而出现如下错误 (为什麽我的ubuntu里面只有header? 那我的kernel去哪了?) make -C /usr/src/linux-headers-3.5.0-42-generic/include M=/home/shsu/helloWorld modules make[1]: Entering directory `/usr/src/linux-headers-3.5.0-42-generic/include' make[1]: *** No rule to make target `modules'. Stop. make[1]: Leaving directory `/usr/src/linux-headers-3.5.0-42-generic/include' make: *** [all] Error 2 接着一番估狗之後,发现tldp的教学文章 http://www.tldp.org/LDP/lkmpg/2.6/html/lkmpg.html 我按照里面所说 将-c的路径设定为/lib/modules/3.5.0-42-generic 编译成功! 并且可以成功载入module 所以说,我的linux kerenel实际上放在/lib/modules/这个资料夹下面吗? 但是资料夹名称听起来又怪怪的? 上面的联结又提到一个简单的控制键盘led范例 10.2. Flashing keyboard LEDs 里面引用了 #include <linux/module.h> #include <linux/config.h> #include <linux/init.h> #include <linux/tty.h> #include <linux/kd.h> #include <linux/vt.h> #include <linux/console_struct.h> 里面所有的include我都可以在 /lib/modules/3.5.0-42-generic/build/include中找到 唯独config.h这个档案找不到 编译的时候出现下面这个错误 fatal error: linux/config.h: No such file or directory 我估狗了一下 发现2.6以前是有这个linux/config.h 但是2.6之後改成autoconf.h 但我在/lib/modules/3.5.0-42-generic/build/include中却找不到 又找到一个解法是在source code里面将其改为 #include “/lib/modules/3.5.0-42-generic/build/include/generated/autoconf.h” 但是这样编译的结果却是source code里面一堆东西找不到, 看来这也不是正确的config档案 可否请版友帮忙解疑,我该去哪边include 这个config.h? 最後一个问题,关於路径 我在/lib/modules/3.5.0-42-generic/build/include/linux都能手动找到我需要的.h档 我写make –c /lib/modules/3.5.0-42-generic/build/ 那麽为何我在source code的地方是写 #include <linux/module.h> 而不是 #include <include/linux/module.h> /lib/modules/3.5.0-42-generic/build/和 …../linux/module.h 中间差了一层/include目录不是吗? 谢谢 --



※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 172.249.127.149
1F:推 cobrasgo:这google的到吧,LDD上的source code是2.6.xx,你要找对 10/30 22:43
2F:→ cobrasgo:应的版本才有这个config.h 10/30 22:43
3F:→ cobrasgo:3.x太新了,所以你看LDD时要找旧一点的kernel来玩 10/30 22:44
4F:→ sean72:Yes, but I would like to know there is any replacement 10/31 01:14
5F:→ sean72:for config.h in 3.5 kernel. Maybe Linux moves it to 10/31 01:16
6F:→ sean72:Some other folder? Or it is obsolete? 10/31 01:16
7F:→ mshockwave:kernel在/boot 下面呀 11/02 13:03
8F:→ mshockwave:主要的kernel elf档在/boot 下面 11/02 13:05







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP