LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2847|回复: 8

请教:编译内核时如何指定gcc版本?

[复制链接]
发表于 2005-6-16 11:03:08 | 显示全部楼层 |阅读模式
gcc4.0现在进入了sid,想用它来编译内核试试。

谢谢!
发表于 2005-6-16 11:42:34 | 显示全部楼层
/usr/bin/gcc是个符号连接。指到gcc-3.3-指到gcc-4.0就行了。
回复 支持 反对

使用道具 举报

发表于 2005-6-16 11:52:10 | 显示全部楼层
fei:~# gcc -v
Using built-in specs.
Target: i486-linux
Configured with: ../src/configure -v --enable-languages=c,c++,java,f95,objc,ada,treelang --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --enable-nls --without-included-gettext --enable-threads=posix --program-suffix=-4.0 --enable-__cxa_atexit --enable-libstdcxx-allocator=mt --enable-clocale=gnu --enable-libstdcxx-debug --enable-java-gc=boehm --enable-java-awt=gtk --enable-mpfr --disable-werror --enable-checking=release i486-linux
Thread model: posix
gcc version 4.0.1 20050522 (prerelease) (Debian 4.0.0-9)
不过我编2.4.31出错了--gcc -D__KERNEL__ -I/root/linux-2.4.31/include -Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common -fomit-frame-pointer -pipe -mpreferred-stack-boundary=2 -march=i686 -fno-unit-at-a-time   -DKBUILD_BASENAME=main -c -o init/main.o init/main.c
In file included from /root/linux-2.4.31/include/linux/kernel.h:15,
                 from /root/linux-2.4.31/include/linux/wait.h:13,
                 from /root/linux-2.4.31/include/linux/fs.h:12,
                 from /root/linux-2.4.31/include/linux/capability.h:17,
                 from /root/linux-2.4.31/include/linux/binfmts.h:5,
                 from /root/linux-2.4.31/include/linux/sched.h:9,
                 from /root/linux-2.4.31/include/linux/mm.h:4,
                 from /root/linux-2.4.31/include/linux/slab.h:14,
                 from /root/linux-2.4.31/include/linux/proc_fs.h:5,
                 from init/main.c:15:
/root/linux-2.4.31/include/asm/byteorder.h:14: warning: type qualifiers ignored on function return type
/root/linux-2.4.31/include/asm/byteorder.h:30: warning: type qualifiers ignored on function return type
In file included from /root/linux-2.4.31/include/linux/byteorder/little_endian.h:11,
                 from /root/linux-2.4.31/include/asm/byteorder.h:65,
                 from /root/linux-2.4.31/include/linux/kernel.h:15,
                 from /root/linux-2.4.31/include/linux/wait.h:13,
                 from /root/linux-2.4.31/include/linux/fs.h:12,
                 from /root/linux-2.4.31/include/linux/capability.h:17,
                 from /root/linux-2.4.31/include/linux/binfmts.h:5,
                 from /root/linux-2.4.31/include/linux/sched.h:9,
                 from /root/linux-2.4.31/include/linux/mm.h:4,
                 from /root/linux-2.4.31/include/linux/slab.h:14,
                 from /root/linux-2.4.31/include/linux/proc_fs.h:5,
                 from init/main.c:15:
/root/linux-2.4.31/include/linux/byteorder/swab.h:160: warning: type qualifiers ignored on function return type
/root/linux-2.4.31/include/linux/byteorder/swab.h:173: warning: type qualifiers ignored on function return type
/root/linux-2.4.31/include/linux/byteorder/swab.h:186: warning: type qualifiers ignored on function return type
/root/linux-2.4.31/include/linux/byteorder/swab.h:200: warning: type qualifiers ignored on function return type
In file included from /root/linux-2.4.31/include/linux/prefetch.h:13,
                 from /root/linux-2.4.31/include/linux/list.h:6,
                 from /root/linux-2.4.31/include/linux/wait.h:14,
                 from /root/linux-2.4.31/include/linux/fs.h:12,
                 from /root/linux-2.4.31/include/linux/capability.h:17,
                 from /root/linux-2.4.31/include/linux/binfmts.h:5,
                 from /root/linux-2.4.31/include/linux/sched.h:9,
                 from /root/linux-2.4.31/include/linux/mm.h:4,
                 from /root/linux-2.4.31/include/linux/slab.h:14,
                 from /root/linux-2.4.31/include/linux/proc_fs.h:5,
                 from init/main.c:15:
/root/linux-2.4.31/include/asm/processor.h:75: error: array type has incomplete element type
make: *** [init/main.o] Error 1
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-6-16 17:14:28 | 显示全部楼层
谢谢了,fei版主!
马上去试试!
回复 支持 反对

使用道具 举报

发表于 2005-9-30 20:23:55 | 显示全部楼层
受教!

原来gcc仅是个链接
回复 支持 反对

使用道具 举报

发表于 2005-9-30 20:28:13 | 显示全部楼层
或者编辑Makefile文件。
回复 支持 反对

使用道具 举报

发表于 2005-10-1 06:54:34 | 显示全部楼层
一般来说只需要设一下环境变量就可以了
CC=gcc-3.3
CXX=gcc-3.3

当然,也有些 makefile 写得太臭,那就没办法了。
回复 支持 反对

使用道具 举报

发表于 2005-10-5 17:08:42 | 显示全部楼层
在/usr/bin下我还看到了一些诸如

/usr/bin/gcc -> gcc-4.0
/usr/bin/gcov -> gcov-4.0
/usr/bin/gccbug -> gccbug-4.0

之类的链接,如果我要换一个版本是不是要把这些链接都改为相应版本呢?

如: gcc3.3
/usr/bin/gcc -> gcc-3.3
/usr/bin/gcov -> gcov-3.3
/usr/bin/gccbug -> gccbug-3.3

(我的/usr/bin目录下也有相应的gcc3.3文件.)

谢谢!!
回复 支持 反对

使用道具 举报

发表于 2005-10-5 17:21:11 | 显示全部楼层
gcc is a symlink in /usr/bin. In your system, it points to gcc-3.3, and therefore, if you run gcc, your system still report gcc version 3.3. There several symlinks you need to change, assume you have also installed g++, you should change the followings:

In /usr/bin,

gcc
gccbug
g++
cpp
gcov
i386-linux-gcc
i386-linux-g++
i386-linux-cpp

In /lib,

cpp

Change these to your new gcc-4.0.

Sometimes, Carlos' method is a lot simplier and convenient.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表