引:
现用的gsoap版本是2.7版本,gsoap代码在sourceforge上维护,版本维护工具是SVN。gsoap 2.7有多个小版本,最新的是2.7.17。这个2.7.17版本sf页面,显示的最后修改时间是2016-09-22,点进去后,看到的gsoap_2.7.17.zip的最后修改时间是1010-05-09,这个可能是版本文件夹创建于2016-09-22。OK,扯远了,现在要说的是。综合各种现象判断gsoap2.7是基于openssl 1.0以前的版本,依赖于BIO结构。而openssl自1.0及以后的版本,不在公开BIO的结构,将该结构隐藏起来。凡是外部引用BIO结构的APP或者库,就会报告这个BIO类型的变量size不确定,原因就是openssl 1.0以后BIO结构的声明不再存在于openssl公开的头文件里了。这个东西只是在openssl的changes(相当于release notes)文件里说明了下,官方的文档并没有指出来。而后来爆出来的openssl 0.98及以前的版本存在严重漏洞,会使攻击者获得ssl加密的明文,所以如果要使用ssl加密业务交互重的数据,就要升级到openssl 0.98以上,在openssl官方公布的版本里,0.98以上就是1.0及以上。
综合以上问题,gsoap的2.7版本基本上要被弃用了,要转入到gsoap 2.8版本。今天要做的事情,就是建立gsoap 2.8 + openssl 1.1.0e的体系支持。openssl 1.1.0e的编译前文章已经有叙述解决,本文就gsoap 2.8的编译就以说明。
1.准备
gsoap2.8.46的版本功能增强,依赖的包也相对较多。采用cygwin 32来编译gsoap至少需要以下工具及库:
1)flex develop
2)yacc develop
3)openssl 1.1.0e
2.编译配置
本次的目标是生成cygwin 32里可运行的gsoap工具,如下:
soapcpp2.exe wsdl2h.exe
所以配置就在cygwin里默认。
#./configure --prefix=/usr/local/gsoap-utils
然后就是需要修改gsoap-2.8/config.h的文件,gsoap的配置工具在检测strtod_l/strtof_l等函数的可用性,和make会有不一致的问题。配置工具检测使用gcc去检测,检测到strtod_l/strtof_l函数,只会报告warning,说此函数是隐式声明。而在编译时,用的g++去编译,就会报错,说‘strtod_l’在此作用域中尚未声明。这个是gcc和g++编译器的差异。根本原因在于stdlib.h确实有声明这个函数,libc库确实有这个函数实现,但是stdlib里的声明上却有一个宏来控制,如下:
#if __GNU_VISIBLE
double strtod_l (const char *__restrict, char **__restrict, locale_t);
float strtof_l (const char *__restrict, char **__restrict, locale_t);
而__GNU_VISIBLE又受__GNU_SOURCE的控制,而在编译时,这个宏默认是不打开的,所以就产生了有定义无声明,gcc检测有,g++编译报错的问题。
那么解决这个问题的方法就是,修改gcc检测根据监测结果后生成的config.h,将这个文件里的对应的声明修改。如下:
#define HAVE_STRTOD_L 1
修改为
//#define HAVE_STRTOD_L 1
#define HAVE_STRTOF_L 1
修改为
//#define HAVE_STRTOF_L 1
#define HAVE_STRTOLD_L 1
修改为
//#define HAVE_STRTOLD_L 1
3.编译安装
#make
#make install
make install会将对应的工具安装到--prefixc参数指定的目录/usr/local/gsoap-utils。
附生成后gsoap SDK。
[email protected]_cpyb01 /usr/local/gsoap-utils
$ du -a
1392 ./bin/soapcpp2.exe
15836 ./bin/wsdl2h.exe
17228 ./bin
148 ./include/stdsoap2.h
148 ./include
908 ./lib/libgsoap++.a
564 ./lib/libgsoap.a
948 ./lib/libgsoapck++.a
596 ./lib/libgsoapck.a
1016 ./lib/libgsoapssl++.a
656 ./lib/libgsoapssl.a
1 ./lib/pkgconfig/gsoap++.pc
1 ./lib/pkgconfig/gsoap.pc
1 ./lib/pkgconfig/gsoapck++.pc
1 ./lib/pkgconfig/gsoapck.pc
1 ./lib/pkgconfig/gsoapssl++.pc
1 ./lib/pkgconfig/gsoapssl.pc
10 ./lib/pkgconfig
4702 ./lib
12 ./share/gsoap/custom/chrono_duration.cpp
4 ./share/gsoap/custom/chrono_duration.h
8 ./share/gsoap/custom/chrono_time_point.cpp
4 ./share/gsoap/custom/chrono_time_point.h
8 ./share/gsoap/custom/duration.c
4 ./share/gsoap/custom/duration.h
8 ./share/gsoap/custom/float128.c
4 ./share/gsoap/custom/float128.h
8 ./share/gsoap/custom/int128.c
4 ./share/gsoap/custom/int128.h
8 ./share/gsoap/custom/long_double.c
4 ./share/gsoap/custom/long_double.h
8 ./share/gsoap/custom/long_time.c
4 ./share/gsoap/custom/long_time.h
8 ./share/gsoap/custom/qbytearray_base64.cpp
4 ./share/gsoap/custom/qbytearray_base64.h
8 ./share/gsoap/custom/qbytearray_hex.cpp
4 ./share/gsoap/custom/qbytearray_hex.h
8 ./share/gsoap/custom/qdate.cpp
4 ./share/gsoap/custom/qdate.h
8 ./share/gsoap/custom/qdatetime.cpp
4 ./share/gsoap/custom/qdatetime.h
8 ./share/gsoap/custom/qstring.cpp
4 ./share/gsoap/custom/qstring.h
8 ./share/gsoap/custom/qtime.cpp
4 ./share/gsoap/custom/qtime.h
8 ./share/gsoap/custom/README.txt
8 ./share/gsoap/custom/struct_timeval.c
4 ./share/gsoap/custom/struct_timeval.h
8 ./share/gsoap/custom/struct_tm.c
8 ./share/gsoap/custom/struct_tm.h
8 ./share/gsoap/custom/struct_tm_date.c
4 ./share/gsoap/custom/struct_tm_date.h
216 ./share/gsoap/custom
4 ./share/gsoap/extras/ckdb.c
4 ./share/gsoap/extras/ckdb.h
4 ./share/gsoap/extras/ckdbtest.c
1 ./share/gsoap/extras/ckdbtest.h
4 ./share/gsoap/extras/fault.cpp
4 ./share/gsoap/extras/logging.cpp
1 ./share/gsoap/extras/README.txt
4 ./share/gsoap/extras/soapdefs.h
30 ./share/gsoap/extras
4 ./share/gsoap/import/c14n.h
4 ./share/gsoap/import/dom.h
20 ./share/gsoap/import/ds.h
20 ./share/gsoap/import/ds2.h
4 ./share/gsoap/import/plnk.h
4 ./share/gsoap/import/README.txt
4 ./share/gsoap/import/ref.h
80 ./share/gsoap/import/saml1.h
96 ./share/gsoap/import/saml2.h
1 ./share/gsoap/import/ser.h
4 ./share/gsoap/import/soap12.h
4 ./share/gsoap/import/stdstring.h
4 ./share/gsoap/import/stl.h
4 ./share/gsoap/import/stldeque.h
4 ./share/gsoap/import/stllist.h
4 ./share/gsoap/import/stlset.h
4 ./share/gsoap/import/stlvector.h
4 ./share/gsoap/import/vprop.h
4 ./share/gsoap/import/WS-example.c
4 ./share/gsoap/import/WS-example.h
4 ./share/gsoap/import/WS-Header.h