curl编译.docx
《curl编译.docx》由会员分享,可在线阅读,更多相关《curl编译.docx(25页珍藏版)》请在冰豆网上搜索。
![curl编译.docx](https://file1.bdocx.com/fileroot1/2022-11/16/a87211d5-e899-4535-8a0f-038cb5f7b817/a87211d5-e899-4535-8a0f-038cb5f7b8171.gif)
curl编译
编译libcurl
1libcurl相关链接
http:
//curl.haxx.se/libcurl主页
http:
//curl.haxx.se/download/curl-7.21.3.tar.bz2下载
Http应用
HTTP/FTP客户端开发库:
libwww、libcurl、libfetch以及更多
libcurl使用的简单例子
libcurl编程流程
2编译参考的地址:
http:
//curl.haxx.se/mail/lib-2009-12/0071.html
3编译
使用cygwin+androidsdk1.5+NDK6编译libcurl过程:
3.1环境搭建
1、搭建环境就不说了网上很多。
3.2编译
下载源码,在cygwin命令行中切换到curl目录下。
执行./configure命令,生成curl_config.h文件。
参照上面连接,把没有的包相关宏定义关闭。
通过NDk编译就可以生成静态库。
生成静态库会有一些警告:
把\build\platforms\android-3\arch-arm\usr\include中的time.h,和unistd.h中有问题的代码修改一下,就可以避免警告:
time.h中把externclock_tclock();改成externclock_tclock(void);,把unistd.h中的externunsignedint__page_shift;改成unsignedint__page_shift;就可以避免生成静态库时出现警告。
我的cur_config.h文件如下:
但是生成动态库时会出错:
生成动态库用到的Android.mk文件如下:
我讲源码、头文件所在curl文件夹都放在MK所在目录。
4Android.mk
LOCAL_PATH:
=$(callmy-dir)
common_CFLAGS:
=-Wpointer-arith-Wwrite-strings-Wunused-Winline\
-Wnested-externs-Wmissing-declarations-Wmissing-prototypes-Wno-long-long\
-Wfloat-equal-Wno-multichar-Wsign-compare-Wno-format-nonliteral\
-Wendif-labels-Wstrict-prototypes-Wdeclaration-after-statement\
-Wno-system-headers-DHAVE_CONFIG_H\
include$(CLEAR_VARS)
LOCAL_SRC_FILES:
=axtls.cbase64.cconnect.ccontent_encoding.c\
cookie.ccurl_addrinfo.ccurl_fnmatch.ccurl_gethostname.ccurl_memrchr.ccurl_rand.ccurl_rtmp.ccurl_sspi.ccurl_threads.cdict.ceasy.cescape.cfile.cfileinfo.cformdata.cftp.c\
ftplistparser.cgetenv.cgetinfo.cgopher.cgtls.chash.chmac.chostares.chostasyn.chostip4.chostip6.chostip.chostsyn.chostthre.chttp.chttp_chunks.chttp_digest.c\
http_negotiate.chttp_negotiate_sspi.chttp_ntlm.cidn_win32.cif2ip.cimap.cinet_ntop.cinet_pton.ckrb4.ckrb5.cldap.cllist.cmd4.cmd5.cmemdebug.cmprintf.cmulti.cnetrc.c\
nonblock.cnss.copenldap.cparsedate.cpingpong.cpolarssl.cpop3.cprogress.cqssl.crawstr.crtsp.csecurity.cselect.csendf.cshare.cslist.csmtp.c\
socks.csocks_gssapi.csocks_sspi.cspeedcheck.csplay.cssh.csslgen.cssluse.cstrdup.cstrequal.cstrerror.cstrtok.cstrtoofft.ctelnet.ctftp.c\
timeval.ctransfer.curl.cversion.cwarnless.cwildcard.c\
LOCAL_CFLAGS+=$(common_CFLAGS)
LOCAL_C_INCLUDES+=$(LOCAL_PATH)/include/
LOCAL_MODULE:
=curjni
include$(BUILD_SHARED_LIBRARY)
5cur_config.h
/*lib/curl_config.h.Generatedfromcurl_config.h.inbyconfigure.*/
/*lib/curl_config.h.in.Generatedfromconfigure.acbyautoheader.*/
/*whenbuildinglibcurlitself*/
/*#undefBUILDING_LIBCURL*/
/*Locationofdefaultcabundle*/
/*#undefCURL_CA_BUNDLE*/
/*Locationofdefaultcapath*/
/*#undefCURL_CA_PATH*/
/*todisablecookiessupport*/
/*#undefCURL_DISABLE_COOKIES*/
/*todisablecryptographicauthentication*/
/*#undefCURL_DISABLE_CRYPTO_AUTH*/
/*todisableDICT*/
/*#undefCURL_DISABLE_DICT*/
/*todisableFILE*/
/*#undefCURL_DISABLE_FILE*/
/*todisableFTP*/
/*#undefCURL_DISABLE_FTP*/
/*todisableGopher*/
/*#undefCURL_DISABLE_GOPHER*/
/*todisableHTTP*/
/*#undefCURL_DISABLE_HTTP*/
/*todisableIMAP*/
/*#undefCURL_DISABLE_IMAP*/
/*todisableLDAP*/
/*#undefCURL_DISABLE_LDAP*/
#defineCURL_DISABLE_LDAP1
/*todisableLDAPS*/
/*#undefCURL_DISABLE_LDAPS*/
/*todisablePOP3*/
/*#undefCURL_DISABLE_POP3*/
/*todisableproxies*/
/*#undefCURL_DISABLE_PROXY*/
/*todisableRTSP*/
/*#undefCURL_DISABLE_RTSP*/
/*todisableSMTP*/
/*#undefCURL_DISABLE_SMTP*/
/*todisableTELNET*/
/*#undefCURL_DISABLE_TELNET*/
/*todisableTFTP*/
/*#undefCURL_DISABLE_TFTP*/
/*todisableTLS-SRPauthentication*/
/*#undefCURL_DISABLE_TLS_SRP*/
/*todisableverbosestrings*/
/*#undefCURL_DISABLE_VERBOSE_STRINGS*/
/*tomakeasymbolvisible*/
/*#undefCURL_EXTERN_SYMBOL*/
/*toenablehiddensymbols*/
/*#undefCURL_HIDDEN_SYMBOLS*/
/*UseWindowsLDAPimplementation*/
/*#undefCURL_LDAP_WIN*/
/*whennotbuildingasharedlibrary*/
/*#undefCURL_STATICLIB*/
/*yourEntropyGatheringDaemonsocketpathname*/
/*#undefEGD_SOCKET*/
/*DefineifyouwanttoenableIPv6support*/
/*#undefENABLE_IPV6*/
/*Definetothetypequalifierofarg1forgetnameinfo.*/
#defineGETNAMEINFO_QUAL_ARG1const
/*Definetothetypeofarg1forgetnameinfo.*/
#defineGETNAMEINFO_TYPE_ARG1structsockaddr*
/*Definetothetypeofarg2forgetnameinfo.*/
#defineGETNAMEINFO_TYPE_ARG2socklen_t
/*Definetothetypeofargs4and6forgetnameinfo.*/
#defineGETNAMEINFO_TYPE_ARG46int
/*Definetothetypeofarg7forgetnameinfo