gSOAP移植到NDK

把gSOAP移植(最新版本2.8)到NDK方法非常简单,但就是编译不过:(,总是报告stdsoap2.cpp:933: error: invalid conversion from 'size_t*' to 'socklen_t*'错误,自己又不敢贸然去修改,最后一个老外找到解决方法,希望gSOAP下个版本可以修正。关于gSOAP介绍:gSOAP入门开发实例。

要修正该问题,需修改两个地方:

1、stdsoap2.h 第823行附近

修改前:

#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) ||defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) || defined(__QNX__)
|| defined(QNX) || defined(OS390) || defined(HP_UX) 
# define SOAP_SOCKLEN_T socklen_t

修改后:

#elif defined(__socklen_t_defined) || defined(_SOCKLEN_T) || defined(CYGWIN) ||defined(FREEBSD) || defined(__FreeBSD__) || defined(OPENBSD) || defined(__QNX__)
|| defined(QNX) || defined(OS390) || defined(HP_UX) || defined(__ANDROID__) 
# define SOAP_SOCKLEN_T socklen_t

2、stdsoap2.cpp 第3630行附近

修改前:

#if defined(__GLIBC__) || (defined(HAVE_GETHOSTBYNAME_R) && (defined(FREEBSD) ||defined(__FreeBSD__)))
if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host,&soap->errnum) < 0)
host = NULL;

修改后:

#if defined(__GLIBC__) || (defined(HAVE_GETHOSTBYNAME_R) && (defined(FREEBSD) ||defined(__FreeBSD__))) || defined(__ANDROID__) 
if (gethostbyname_r(addr, &hostent, soap->buf, SOAP_BUFLEN, &host,&soap->errnum) < 0) 
host = NULL;

三、MAKEFILE增加__ANDROID__宏定义

附Makefile.am文件:

AUTOMAKE_OPTIONS = foreign

noinst_LIBRARIES = libgSClient.a

libgSClient_a_SOURCES = \
		gSClient.cpp \
		soapC.cpp \
		soapClient.cpp \
		soapClientLib.cpp \
		gSClient.h \
		soapdrmspProxy.h \
		soapH.h \
		soapStub.h \
		stdsoap2.cpp \
		stdsoap2.h

INCLUDES = 

AM_CXXFLAGS = -DLINUX -D__ANDROID__

你可能感兴趣的:(gsoap)