[问题]如何获得Ubuntu的Linux-2.6.15-26-386内核源代码?(写驱动用)

软件和网站开发以及相关技术探讨
回复
头像
ubuntu_amateur
帖子: 79
注册时间: 2006-06-10 14:58
来自: China

[问题]如何获得Ubuntu的Linux-2.6.15-26-386内核源代码?(写驱动用)

#1

帖子 ubuntu_amateur » 2006-08-04 11:03

如题。
写驱动,在编译时,都要include /usr/include/linux/目录的一些header文件,
但,在我用Ubuntu6.06(DapperDrake)PC(Intel x86)alternate install CD安装的系统中,
该目录只有一个.config文件。

现在想获取一份Linux-2.6.15-26-386内核源代码,如何获得?(http://kernel.org/不提供这一版本Kernel source)
谢谢~
头像
ubuntu_amateur
帖子: 79
注册时间: 2006-06-10 14:58
来自: China

#2

帖子 ubuntu_amateur » 2006-08-04 11:07

头像
ubuntu_amateur
帖子: 79
注册时间: 2006-06-10 14:58
来自: China

#3

帖子 ubuntu_amateur » 2006-08-04 11:20

现在编译,gcc -c khello.c,出现如下错误:

In file included from /usr/include/linux/sched.h:16,
from /usr/include/linux/module.h:9,
from khello.c:2:
/usr/include/linux/signal.h:2:2: warning: #warning "You should include <signal.h>. This time I will do it for you."
In file included from /usr/include/linux/resource.h:4,
from /usr/include/linux/sched.h:79,
from /usr/include/linux/module.h:9,
from khello.c:2:
/usr/include/linux/time.h:9: error: redefinition of `struct timespec'
/usr/include/linux/time.h:15: error: redefinition of `struct timeval'
/usr/include/linux/time.h:20: error: redefinition of `struct timezone'
/usr/include/linux/time.h:47: error: redefinition of `struct itimerval'
In file included from khello.c:2:
/usr/include/linux/module.h:41: error: field `attr' has incomplete type
/usr/include/linux/module.h:49: error: field `kobj' has incomplete type

请问:在哪里可以设置include文件路径? 例如VC Tools->Options->Directory那种。
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#4

帖子 eexpress » 2006-08-04 11:44

include默认的路径吧,反正又不能移动地方。自己带的直接加路径
● 鸣学
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#5

帖子 eexpress » 2006-08-04 11:46

redefinition of `struct timespec'

重复定义先搞好啊。自己的头文件,加ifndef xxx; define xxxx; endif 是最可靠的。
● 鸣学
头像
ubuntu_amateur
帖子: 79
注册时间: 2006-06-10 14:58
来自: China

#6

帖子 ubuntu_amateur » 2006-08-05 16:48

现在我从网上下一个open source的driver来编译,提示信息如下:

***** Using kernel source in /lib/modules/2.6.15-26-386/build *****

make modules -C /lib/modules/2.6.15-26-386/build M=/home/amateur/EVB/driver/mytest-linux-0.9.5/kernel
make: *** /lib/modules/2.6.15-26-386/build: No such file or directory. Stop.
make: *** [all] Error 2


请问:内核源代码下载后要不要编译,如果版本不符(比如说,2.6.15的用了2.6.18或2.6.10),编译会有什么状况?
步骤是不是这样的:
cd /usr/src/linux/linux-2.6.15
make dep
make clean
make xconfig
make install

哪位大侠升级过Ubuntu内核的,帮忙指点下
头像
leal
帖子: 1119
注册时间: 2005-08-29 14:49
来自: 杭州
联系:

#7

帖子 leal » 2006-08-05 23:13

开发驱动并一定要有完整的 内核源代码,但一定要安装上 对应内核版本(uname -r)的 内核 头文件
(kernel headers 类似这个名字的包吧)

另外看看 你的 /lib/modules/2.6.15-26-386/build 有没有指向你安装的 内核头文件 目录
用心×恒 | 豆瓣 | 门户 | Blog
回复