Building GCC 4.2.1 On Solaris

本文介绍在 Solaris 10 上使用 GCC 编译器的方法及注意事项。由于 Solaris 10 默认提供的 GCC 版本较旧(3.4.3),为了获得更好的编译效果,推荐使用 GCC 4.0 或更高版本进行 32 位和 64 位应用的交叉编译。文章提供了 GCC 的安装步骤,并推荐配置选项。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The default version of gcc shipped with Solaris 10 is 3.4.3 and is found in /usr/sfw/bin. The current available version of gcc (released is) 4.3. So the version Sun makes available dates from 2005...


[allen@tecra:pciutils-3.0.0]uname -a
SunOS tecra 5.11 snv_85 i86pc i386 i86pc Solaris

[allen@tecra:pciutils-3.0.0]gcc -v
Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.11/3.4.3/specs
Configured with: /builds2/sfwnv-gate/usr/src/cmd/gcc/gcc-3.4.3/configure --prefix=/usr/sfw --with-as=/usr/sfw/bin/gas --with-gnu-as --with-ld=/usr/ccs/bin/ld --without-gnu-ld --enable-languages=c,c++,f77,objc --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-20050802)


One assumes that Sun has no interest in letting Solaris users use more modern versions of gcc and would rather we use their own compiler.

But to properly compile on Solaris 10 with 64bit see notes from gcc.gnu.org

"
i?86-*-solaris2.10
Use this for Solaris 10 or later on x86 and x86-64 systems. This configuration is supported by GCC 4.0 and later versions only.

It is recommended that you configure GCC to use the GNU assembler in /usr/sfw/bin/gas but the Sun linker, using the options --with-gnu-as --with-as=/usr/sfw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld"


So gcc 4.0 is the lowest version you can use for cross-compiling 32bit and 64bit applications on Solaris 10...


So we have to build our own gcc to do the firebird compilation, here's how you do it....
1. Download a copy of the gcc source (e.g. gcc-4.1.2.tar.gz) from gcc.gnu.org
2. Install gnu tar, solaris tar has problems extracting the source from the gcc tar file.
3. You will probably need to install libintl too (you can get a pre-built version of this froim www.sunfreeware.com)
4. gunzip gcc-4.1.2.tar.gz
5. /usr/local/bin/tar -xvf gcc-4.1.2.tar
6. cd gcc-4.1.2
7. mkdir objdir
8. cd objdir
9. ../configure --with-gnu-as --with-as=/usr/sfw/bin/gas --without-gnu-ld --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++
10. gmake
11. as root - make install

Your new version of gcc will be installed in /usr/local/bin

Appendix:
1. For gcc on Solaris, this site is very helpful.
http://www.softpanorama.org/Lang/gcc.shtml
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值