〖Linux〗Qt5.2.0+gsoap开发Android的NDK程序遇到错误的解决

1.  error: cannot convert ‘int*’ to ‘hostent**’ for argument ‘5’ to..

 原因分析:

  缺少的宏定义,导致使用了错误的函数原型。

  被调用的函数是:

  gethostbyname_r(addr,&hostent,soap->buf,SOAP_BUFLEN,&soap->errnum)

  正确的调用函数应该是:

  gethostbyname_r(addr,&hostent,soap->buf,SOAP_BUFLEN,&host,&soap->errnum)

 解决方法:

 1)修改文件stdsoap2.h,找到如下片段(大约在837行的位置)

/* Portability: define SOAP_SOCKLEN_T */
#if defined(_AIX) || defined(AIX)
# if defined(_AIX43)
#  define SOAP_SOCKLEN_T socklen_t
# else
#  define SOAP_SOCKLEN_T int
# endif
#elif defined(SOCKLEN_T)
# 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)
# define SOAP_SOCKLEN_T socklen_t
#elif defined(IRIX) || defined(WIN32) || defined(__APPLE__) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) || defined(HP_UX)
# define SOAP_SOCKLEN_T int
#else
# define SOAP_SOCKLEN_T size_t
#endif

 修改为:

/* Portability: define SOAP_SOCKLEN_T */
#if defined(_AIX) || defined(AIX)
# if defined(_AIX43)
#  define SOAP_SOCKLEN_T socklen_t
# else
#  define SOAP_SOCKLEN_T int
# endif
#elif defined(SOCKLEN_T)
# 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(__ANDROID__)
# define SOAP_SOCKLEN_T socklen_t
#elif defined(IRIX) || defined(WIN32) || defined(__APPLE__) || defined(SUN_OS) || defined(OPENSERVER) || defined(TRU64) || defined(VXWORKS) || defined(HP_UX)
# define SOAP_SOCKLEN_T int
#else
# define SOAP_SOCKLEN_T size_t
#endif

 2)修改文件stdsoap2.cpp,找到如下片段(大约在3698行的位置)

#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;

 

2. Cannot find Android tool: "/opt/android/sdk/tools/android"

 原因分析:

  Qt搜索了默认的Android SDK目录,即使你指定了新的路径也可能会报这个错

 解决办法:

  假定安装的Android SDK目录是/media/Source/android-sdk-linux,在终端输入命令

  sudo mkdir -p /opt/android

  sudo ln -s /media/Source/android-sdk-linux /opt/android/sdk

你可能感兴趣的:(android)