fedora14 编译ldd3的源码

直接到example下的某个目录如scull下去make,会出现一堆错误
说明一下,fedora14带内核源码的头文件(或者yum install kernel-devel安装这些头文件),没带源码,但是对于编译ldd3里的的例子,这些头文件就足够了
并且Makefile已经指定了正确的内核目录
#KERNELDIR ?= /lib/modules/$(shell uname -r)/build

所以出现的这些错误,仅仅是由内核版本不一致造成的
ldd3的例子是2.6.10内核时代的东东,而fc14的内核版本是2.6.35.6-45
2.6.35内核中更新了的一些数据结构,所以用当时参照2.6.10内核写的ldd3的例子就很可能用新内核去编译时而出错
解决方法是让ldd的例子去适应新的内核版本或者给换个2.6.10的内核去编译
http://hi.baidu.com/%B3%C1%BC%C5%B5%C4%B9%C2%B3%C7/blog/item/570c3c52760aa62843a75b2a.html/cmtid/2fcadaf301a692cc7831aa4d
http://blog.163.com/xdd123www@126/blog/static/754751472008413102629279/
http://blog.chinaunix.net/space.php?uid=26100163&do=blog&id=2149411
error: ‘system_utsname’ undeclared
新版本没有这个东东,干脆就在那个文件里定义一个char *system_utsname="x86";然后在代码中去掉.machine



如果想拥有一个完整的内核源代码来代替fc14自带的头文件,可以如下去做
到下面链接下载14的kernel即kernel-2.6.35.6-45.fc14.src.rpm 
http://download.fedora.redhat.com/pub/fedora/linux/releases/14/Fedora/source/SRPMS/
另外,15的
http://download.fedora.redhat.com/pub/fedora/linux/releases/15/Fedora/source/SRPMS/
而13 12 11 10 9 等在此处
http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/
比如
http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/12/Fedora/source/SRPMS/
目前的情况是这样,但不久后14 15可能也会搬到archives去
说明:也可到www.kernel.org去下某个版本的内核源码,但是下载编译后,要给fc14换上(安装)这个内核镜像,
这样以后用这个版本的内核源码编译的内核模块在本机insmod时才能顺利通过
执行

rpm -uvh  kernel-2.6.35.6-45.fc14.src.rpm
执行 

cd  /root/rpmbuild/SPECS
说明:fedora14默认/root/rpmbuild为srpm的主目录(貌似以前版本为 /usr/src/redhat/)
refer to http://help.directadmin.com/item.php?id=381
执行以下命令,出现错误
[root@localhost SPECS]# rpmbuild -bp --target $(uname -m) kernel.spec 
Building target platforms: i686
Building for target i686
error: Failed build dependencies:
	xmlto is needed by kernel-2.6.35.6-45.fc14.i686
	asciidoc is needed by kernel-2.6.35.6-45.fc14.i686
	elfutils-devel is needed by kernel-2.6.35.6-45.fc14.i686
	perl(ExtUtils::Embed) is needed by kernel-2.6.35.6-45.fc14.i686
把缺少的东东分别安装一下
yum install xmlto
yum intsall asciidoc
yum install elfutils-devel
yum install perl-ExtUtils-Embed.noarch (this refers to http://joysofprogramming.com/install-perl-extutils-embed-fedora-rhel/)
重新执行上面那个命令,
源码已经塞进了 /root/rpmbuild/BUILD
[root@localhost rpmbuild]# ls
BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS
[root@localhost rpmbuild]# cd BUILD
[root@localhost BUILD]# ls
kernel-2.6.35.fc14
[root@localhost BUILD]# ls kernel-2.6.35.fc14/
linux-2.6.35.i686  vanilla-2.6.35
[root@localhost BUILD]# ls kernel-2.6.35.fc14/linux-2.6.35.i686/
arch                      config-rhel-generic     fs             net
block                     configs                 include        README
config-arm                config-s390x            init           REPORTING-BUGS
config-debug              config-sparc64-generic  ipc            samples
config-generic            config-x86_64-generic   Kbuild         scripts
config-i686-PAE           config-x86-generic      kernel         security
config-ia64-generic       COPYING                 lib            sound
config-nodebug            CREDITS                 MAINTAINERS    tools
config-powerpc32-generic  crypto                  Makefile       usr
config-powerpc32-smp      Documentation           merge.pl       virt
config-powerpc64          drivers                 mm
config-powerpc-generic    firmware                modules.order
[root@localhost BUILD]# cd kernel-2.6.35.fc14/linux-2.6.35.i686/
[root@localhost linux-2.6.35.i686]# 

执行
[root@localhost linux-2.6.35.i686]# vi Makefile 
/*修改line 4为
EXTRAVERSION = .6-45.fc14.i686
要保证与uname -r的结果一致
*/
[root@localhost linux-2.6.35.i686]# make mrproper
[root@localhost linux-2.6.35.i686]# cp configs/kernel-2.6.35.6-i686.config .config 
[root@localhost linux-2.6.35.i686]# 

或者考/boot下的config来用也行
执行
make

执行
make modules
现在已经达到了一个编译过的完整的内核源码了,
/lib/modules/2.6.35.6-45.fc14.i686/build/本来就存在并连接到/usr/src/kernels/2.6.35.6-45.fc14.i686,
现在将其连接到/root/rpmbuild/BUILD/kernel-2.6.35.fc14/linux-2.6.35.i686/即可

(这个貌似也不必自己动手去做,执行过make install 时会自动修正链接)
执行
make modules_install
**********************************************************************************************************************************************************
如果想安装一下刚才编译过的内核

执行
make install
(系统将会把vmlinuz和System.map复制到/boot目录下并自动加上$(uname -r)后缀,
同时修改grub/boot/grub/menu.lst,2.6以前版本需要手动拷贝vmlinuz和System.map)
重启即可见到新内核

对于grub.conf(menu.list仅是一个指向他的符号)
# grub.conf generated by anacondahttp://write.blog.csdn.net/postedit/6765297
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-LogVol02
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Fedora (2.6.35.6-45.fc14.i686)
    root (hd0,0)
    kernel /vmlinuz-2.6.35.6-45.fc14.i686 ro root=/dev/mapper/VolGroup-LogVol02 rd_LVM_LV=VolGroup/LogVol02 rd_LVM_LV=VolGroup/LogVol00 rd_NO_LUKS rd_NO_MD rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYTABLE=us rhgb quiet
    initrd /initramfs-2.6.35.6-45.fc14.i686.img
kernel所指文件是内核镜像
initrd 所指img文件用于引导硬件到实际内核vmlinuz能够接管并继续引导的状态
而System.map是内核导出的符号表
这三种文件都会存在/boot下
**********************************************************************************************************************************************************
看来fedora下重新安装一个内核还是蛮方便的
refer to
http://blog.csdn.net/qinlicang/article/details/4709225
http://blog.csdn.net/wishmiss/article/details/5674076
http://os.51cto.com/art/201003/188351.htm
http://www.xker.com/page/e2007/0723/28030.html
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值