1. 程式人生 > >Cygwin下編譯gsoap 2.8.46

Cygwin下編譯gsoap 2.8.46

gsoap openssl cygwin strtod_l

引:

現用的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

Cygwin下編譯gsoap 2.8.46