红联Linux门户
Linux帮助

Solaris搭建64位C语言开发环境

发布时间:2014-06-10 09:40:57来源:红联作者:velcbo
刚来公司时,公司的C程序还是32位的。后来我阅读了一些资料,觉得64位的程序才是真正的趋势,所以就开始尝试着开发64位的程序。这篇文章介绍如何在Solaris下搭建64位C语言开发环境,希望给需要的朋友一点帮助。

(1)gcc

Solaris的/usr/sfw/bin/gcc可以用来编译64位C程序,但是需要加-m64编译选项。此外也可以从gcc的官网下载gcc源代码,自行编译安装,但是要注意编译出来的gcc需要是64位的。

(2)gdb

调试64位C程序需要64位的gdb,gdb的安装步骤如下(以7.6版本为例):

1)gunzip gdb-7.6.tar.gz
2)tar xvf gdb-7.6.tar
3)cd gdb-7.6
4)export CC="/usr/sfw/bin/gcc -m64"
5)./configure -prefix=“/…/…(a folder path)”
6)make
7)make install

需要注意的是,目前gdb的最新版本是7.7,在Solaris下编译会有错误。

(3)参考资料

个人认为Oracle的这本《Solaris 64-bit Developer’s Guide》,是在Solaris下开发64位C程序最好的资料。每一位C语言开发者都应该看一下,相信都能受益匪浅。[code]bfd/cache.c doesn't compile with gcc -m64 on Solaris

On current mainline, bfd/cache.c doesn't compile with gcc -m64 on
Solaris 8 to 11:

cc1: warnings being treated as errors
/vol/src/gnu/gdb/gdb-7.7/bfd/cache.c: In function 'bfd_cache_max_open':
/vol/src/gnu/gdb/gdb-7.7/bfd/cache.c:85: error: comparison between signed and unsigned integer expressions

This breaks both binutils 2.24 and gdb 7.7 builds and is a regression
from the previous releases.

The error is about

&& rlim.rlim_cur != RLIM_INFINITY)

where has

typedef unsigned long rlim_t;
#define RLIM_INFINITY (-3l)

While I've raised the issue with Oracle, this won't help for shipping
Solaris releases. The problem can easily be avoided by casting
RLIM_INFINITY to rlim_t, as the following patch does.

Ok for mainline and the binutils 2.24 branch?

Rainer

2014-02-06 Rainer Orth CeBiTec.Uni-Bielefeld.DE>

* cache.c (bfd_cache_max_open): Cast RLIM_INFINITY to rlim_t.

--- bfd/cache.c 2013/12/08 04:55:47 1.1
+++ bfd/cache.c 2014/02/06 16:13:27
-82,7 +82,7 bfd_cache_max_open (void)
#ifdef HAVE_GETRLIMIT
struct rlimit rlim;
if (getrlimit (RLIMIT_NOFILE, &rlim) == 0
- && rlim.rlim_cur != RLIM_INFINITY)
+ && rlim.rlim_cur != (rlim_t) RLIM_INFINITY)
max = rlim.rlim_cur / 8;
else
#endif /* HAVE_GETRLIMIT */

--

--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University[/code]作者:yigeshouyiren
文章评论

共有 0 条评论