使用的libcurl版本为:android7.1–0x073201 android4.4–0x073000
事情缘由
需将android4.4上的日志上传功能移植到android7.1上,但是移植好后出现了如下截图的问题
过程
7.1和4.4有一点的区别很重要,那就是参数类型的位数不一样,7.1使用的是64位,4.4用的是32位的。在相同的源码情况下,4.4正常使用,7.1出现了如上截图的问题,那就必须是libcurl库的问题了,使用grep命令找到错误信息出现的位置加上fprintf(stderr,"…")相应的函数名。发现如下图SIZEOF_SIZE_T未定义、CURL_SIZEOF_CURL_OFF_T为8,andoird4.4上的SIZEOF_SIZE_T为4、CURL_SIZEOF_CURL_OFF_T也为4,归根到底就是默认配置的位数不配置导致出错。因此#if (8 < CURL_SIZEOF_CURL_OFF_T)就可以解决问题了,如下图为成功的消息打印。
附上正常使用的源码:
/***************************************************************************
* _ _ ____ _
* Project ___| | | | _ \| |
* / __| | | | |_) | |
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
* are also available at https://curl.haxx.se/docs/copyright.html.
*
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
* copies of the Software, and permit persons to whom the Software is
* furnished to do so, under the terms