一、 系统环境
操作系统原始环境如下:
$ uname -a
SunOS sol10u6 5.10 Generic_137138-09 i86pc i386 i86pc
$ /usr/sfw/bin/gcc -v
Reading specs from /usr/sfw/lib/gcc/i386-pc-solaris2.10/3.4.3/specs
Configured with: /builds/sfw10-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++ --enable-shared
Thread model: posix
gcc version 3.4.3 (csl-sol210-3_4-branch+sol_rpath)
$ /usr/ccs/bin/ld -V
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.490
$ gmake --version
GNU Make 3.80
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
$ /usr/sfw/bin/gld --version
GNU ld version 2.15
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License. This program has absolutely no warranty.
二、 安装补丁包
Solaris 10 x86自带的gcc版本为3,4.3,指定链接器为/usr/ccs/bin/ld,但是在poco对应gcc编译器的配置文件build/config/SunOS-GCC中,指定的链接器参数是GNU ld格式的,编译时会报出许多跟链接器有关的警告及错误,所以,必须强制gcc使用GNU ld。我不知道gcc是不是可以通过命令行参数来指定所使用的链接器,我是通过重命名系统自带的/usr/ccs/bin/ld文件,然后在/usr/ccs/bin/下建立一个符号连接,指向GNU ld来达到这一目的的。
系统自带的GNU ld版本为2.15,此版本的GNU ld有一个bug,在Solaris 10中,将许多在Solaris 9中原本处于.bbs段的符号移到了.abs段,而GNU ld不会处理.abs中导出的符号,导致在链接时报许多符号找不到的错误。在GNU binutils 2006年的bug邮件列表里详细讨论了此问题及解决方法。我不太确定GNU ld具体是在哪一个版本里修正了此bug,我下载的2.21.1版本的binutil二进制包中已经修正了此bug。binutils依赖于以下的包:libiconv,libintl,zlib,libgcc-3.4.6或者c-3.4.6。必须安装这些包才能顺利编译poco,各个包安装的先后次序没有要求。安装完各个包之后,先将系统自带的/usr/ccs/bin/ld重命名,然后ln -s /usr/local/bin/ld ld建议一个符号连接。
www.sourceware.org/bugzilla/show_bug.cgi?id=1021
通过命令pkgadd -d filename安装以下包:
binutils-2.21.1a-sol10-x86-local
gcc-3.4.6-sol10-x86-local
libiconv-1.14-sol10-x86-local
libintl-3.4.0-sol10-x86-local
zlib-1.2.7-sol10-x86-local
安装完成后环境如下:
$ which gcc
/usr/local/bin/gcc
$ /usr/local/bin/gcc -v
Reading specs from /usr/local/lib/gcc/i386-pc-solaris2.10/3.4.6/specs
Configured with: ../configure --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --enable-shared --enable-languages=c,c++,f77
Thread model: posix
gcc version 3.4.6
$ ls -l /usr/ccs/bin/ld
lrwxrwxrwx 1 root root 17 Jan 25 11:15 /usr/ccs/bin/ld -> /usr/local/bin/ld
$ /usr/local/bin/ld --version
GNU ld (GNU Binutils) 2.21.1
Copyright 2011 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
三、 修改poco配置文件
1.编辑build/config/SunOS-GCC文件,找到以下行:
#
# System Specific Libraries
#
SYSLIBS = -lpthread -ldl -lrt
修改为:
#
# System Specific Libraries
#
SYSLIBS = -lrt -lsocket -lnls
On S10 libpthread is an empty filter on libc, which is a fancy way of saying that all of the code in libthread moved to libc and libpthread is just a shell saying as much so that older programs linked with libpthread can still run.
gld is choking on Solaris libraries that are filters.
http://www.mentby.com/Group/sqlite-users/build-problem-of-sqlite-36142-on-solaris-10-with-gcc-440.html
2.编辑build/rules/global文件,找到以下行:
#
# Build Include directory List
#
INCLUDE = $(foreach p,$(POCO_ADD_INCLUDE),-I$(p)) -Iinclude $(foreach p,$(COMPONENTS),-I$(POCO_BASE)/$(p)/$(INCDIR))
#
# Build Library Directory List
#
LIBRARY = $(foreach p,$(POCO_ADD_LIBRARY),-L$(p)) -L$(LIBPATH:) $(POCO_LIBRARY)
修改为:
#
# Build Include directory List
#
INCLUDE = $(foreach p,$(POCO_ADD_INCLUDE),-I$(p)) -Iinclude -I/usr/sfw/include -
I/usr/sfw/include/mysql $(foreach p,$(COMPONENTS),-I$(POCO_BASE)/$(p)/$(INCDIR))
#
# Build Library Directory List
#
LIBRARY = $(foreach p,$(POCO_ADD_LIBRARY),-L$(p)) -L/usr/sfw/lib -L$(LIBPATH) $(
POCO_LIBRARY)
======
3.运行configure生成配置文件:
$ ./configure --prefix=$HOME/poco --config=SunOS-GCC --omit=Data/ODBC,Data/MySQL
Configured for SunOS-GCC
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。