﻿<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>学习日记 &#187; curl</title>
	<atom:link href="https://www.softwareace.cn/?feed=rss2&#038;tag=curl" rel="self" type="application/rss+xml" />
	<link>https://www.softwareace.cn</link>
	<description>时刻想着为自己的产品多做一些对他好的事情</description>
	<lastBuildDate>Fri, 20 Mar 2026 06:58:28 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>curl_easy_perform 返回值说明</title>
		<link>https://www.softwareace.cn/?p=529</link>
		<comments>https://www.softwareace.cn/?p=529#comments</comments>
		<pubDate>Mon, 19 Aug 2013 09:42:39 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[libcurl]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=529</guid>
		<description><![CDATA[response=curl_easy_perform(curl); response返回的状态值 CURLE_ [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>response=curl_easy_perform(curl);<br />
response返回的状态值<br />
CURLE_OK: printf(&#8220;send ok!\n&#8221;);<br />
CURLE_HTTP_POST_ERROR: printf(&#8220;post error!\n&#8221;);<br />
CURLE_COULDNT_CONNECT: printf(&#8220;cannot connect to server\n&#8221;);</p>
<p>CURLE_OK = 0, 0: no error<br />
CURLE_UNSUPPORTED_PROTOCOL, 1: unsupported protocol<br />
CURLE_FAILED_INIT, 2: failed init<br />
CURLE_URL_MALFORMAT, 3: URL using bad/illegal format or missing URL<br />
CURLE_URL_MALFORMAT_USER, 4: unknown error<br />
CURLE_COULDNT_RESOLVE_PROXY, 5: couldn&#8217;t resolve proxy name<br />
CURLE_COULDNT_RESOLVE_HOST, 6: couldn&#8217;t resolve host name<br />
CURLE_COULDNT_CONNECT, 7: couldn&#8217;t connect to server<br />
CURLE_FTP_WEIRD_SERVER_REPLY, 8: FTP: weird server reply<br />
CURLE_FTP_ACCESS_DENIED,<br />
CURLE_FTP_USER_PASSWORD_INCORRECT, 10: unknown error<br />
CURLE_FTP_WEIRD_PASS_REPLY, 11: FTP: unknown PASS reply<br />
CURLE_FTP_WEIRD_USER_REPLY, 12: FTP: unknown USER reply<br />
CURLE_FTP_WEIRD_PASV_REPLY, 13: FTP: unknown PASV reply<br />
CURLE_FTP_WEIRD_227_FORMAT, 14: FTP: unknown 227 response format<br />
CURLE_FTP_CANT_GET_HOST, 15: FTP: can&#8217;t figure out the host in the PASV response<br />
CURLE_FTP_CANT_RECONNECT, 16: FTP: can&#8217;t connect to server the response code is unknown<br />
CURLE_FTP_COULDNT_SET_BINARY, 17: FTP: couldn&#8217;t set binary mode<br />
CURLE_PARTIAL_FILE, 18: Transferred a partial file<br />
CURLE_FTP_COULDNT_RETR_FILE, 19: FTP: couldn&#8217;t retrieve (RETR failed) the specified file<br />
CURLE_FTP_WRITE_ERROR, 20: FTP: the post-transfer acknowledge response was not OK<br />
CURLE_FTP_QUOTE_ERROR, 21: FTP: a quote command returned error<br />
CURLE_HTTP_RETURNED_ERROR, 22: HTTP response code said error<br />
CURLE_WRITE_ERROR, 23: failed writing received data to disk/application<br />
CURLE_MALFORMAT_USER, 24: unknown error<br />
CURLE_UPLOAD_FAILED, 25: upload failed (at start/before it took off)<br />
CURLE_READ_ERROR, 26: failed to open/read local data from file/application<br />
CURLE_OUT_OF_MEMORY, 27: out of memory</p>
<p>CURLE_OPERATION_TIMEOUTED, 28: a timeout was reached<br />
CURLE_FTP_COULDNT_SET_ASCII, 29: FTP could not set ASCII mode (TYPE A)<br />
CURLE_FTP_PORT_FAILED, 30: FTP command PORT failed<br />
CURLE_FTP_COULDNT_USE_REST, 31: FTP command REST failed<br />
CURLE_FTP_COULDNT_GET_SIZE, 32: FTP command SIZE failed<br />
CURLE_HTTP_RANGE_ERROR, 33: a range was requested but the server did not deliver it<br />
CURLE_HTTP_POST_ERROR, 34: internal problem setting up the POST<br />
CURLE_SSL_CONNECT_ERROR, 35: SSL connect error<br />
CURLE_BAD_DOWNLOAD_RESUME, 36: couldn&#8217;t resume download<br />
CURLE_FILE_COULDNT_READ_FILE, 37: couldn&#8217;t read a file:// file<br />
CURLE_LDAP_CANNOT_BIND, 38: LDAP: cannot bind<br />
CURLE_LDAP_SEARCH_FAILED, 39: LDAP: search failed<br />
CURLE_LIBRARY_NOT_FOUND, 40: a required shared library was not found</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=529</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>curl_easy_perform  crash</title>
		<link>https://www.softwareace.cn/?p=528</link>
		<comments>https://www.softwareace.cn/?p=528#comments</comments>
		<pubDate>Mon, 19 Aug 2013 04:37:23 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[libcurl]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=528</guid>
		<description><![CDATA[把 curl_easy_setopt 中的函数指针 都改为 static &#160;]]></description>
				<content:encoded><![CDATA[<p>把 curl_easy_setopt 中的函数指针 都改为 static</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=528</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>curl_easy_setopt函数介绍</title>
		<link>https://www.softwareace.cn/?p=527</link>
		<comments>https://www.softwareace.cn/?p=527#comments</comments>
		<pubDate>Mon, 19 Aug 2013 02:17:00 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[C++]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[libcurl]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=527</guid>
		<description><![CDATA[本节主要介绍curl_easy_setopt中跟http相关的参数。注意本节的阐述都是以libcurl作为主体 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>本节主要介绍curl_easy_setopt中跟http相关的参数。注意本节的阐述都是以libcurl作为主体，其它为客体来阐述的。<br />
1.     CURLOPT_URL<br />
设置访问URL<br />
2.       CURLOPT_WRITEFUNCTION，CURLOPT_WRITEDATA<br />
回调函数原型为：size_t function( void *ptr, size_t size, size_t nmemb, void *stream); 函数将在libcurl接收到数据后被调用，因此函数多做数据保存的功能，如处理下载文件。CURLOPT_WRITEDATA 用于表明CURLOPT_WRITEFUNCTION函数中的stream指针的来源。<br />
3.      CURLOPT_HEADERFUNCTION，CURLOPT_HEADERDATA<br />
回调函数原型为 size_t function( void *ptr, size_t size,size_t nmemb, void *stream); libcurl一旦接收到http 头部数据后将调用该函数。CURLOPT_WRITEDATA 传递指针给libcurl，该指针表明CURLOPT_HEADERFUNCTION 函数的stream指针的来源。<br />
4.       CURLOPT_READFUNCTION CURLOPT_READDATA<br />
libCurl需要读取数据传递给远程主机时将调用CURLOPT_READFUNCTION指定的函数，函数原型是：size_t function(void *ptr, size_t size, size_t nmemb,void *stream). CURLOPT_READDATA 表明CURLOPT_READFUNCTION函数原型中的stream指针来源。<br />
5.       CURLOPT_NOPROGRESS，CURLOPT_PROGRESSFUNCTION，CURLOPT_PROGRESSDATA<br />
跟数据传输进度相关的参数。CURLOPT_PROGRESSFUNCTION 指定的函数正常情况下每秒被libcurl调用一次，为了使CURLOPT_PROGRESSFUNCTION被调用，CURLOPT_NOPROGRESS必须被设置为false，CURLOPT_PROGRESSDATA指定的参数将作为CURLOPT_PROGRESSFUNCTION指定函数的第一个参数<br />
6.       CURLOPT_TIMEOUT，CURLOPT_CONNECTIONTIMEOUT:<br />
CURLOPT_TIMEOUT 由于设置传输时间，CURLOPT_CONNECTIONTIMEOUT 设置连接等待时间<br />
7.       CURLOPT_FOLLOWLOCATION<br />
设置重定位URL<br />
CURLOPT_RANGE: CURLOPT_RESUME_FROM:<br />
断点续传相关设置。CURLOPT_RANGE 指定char *参数传递给libcurl，用于指明http域的RANGE头域，例如：<br />
表示头500个字节：bytes=0-499<br />
表示第二个500字节：bytes=500-999<br />
表示最后500个字节：bytes=-500<br />
表示500字节以后的范围：bytes=500-<br />
第一个和最后一个字节：bytes=0-0,-1<br />
同时指定几个范围：bytes=500-600,601-999<br />
CURLOPT_RESUME_FROM 传递一个long参数给libcurl，指定你希望开始传递的<br />
偏移量。</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=527</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>error LNK2001: 无法解析的外部符号 _curl_easy_init</title>
		<link>https://www.softwareace.cn/?p=526</link>
		<comments>https://www.softwareace.cn/?p=526#comments</comments>
		<pubDate>Fri, 16 Aug 2013 06:42:03 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[开发问题]]></category>
		<category><![CDATA[curl]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=526</guid>
		<description><![CDATA[最近用curl做应用。。 下了最新的curl-7.21.6 用VS2008编译，生成静态库及动态库。 开始想用 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>最近用curl做应用。。<br />
下了最新的curl-7.21.6<br />
用VS2008编译，生成静态库及动态库。<br />
开始想用静态库，发现不行， 换成动态库：<br />
添加头文件目录：　工具-》选项-》项目和解决方案-》VC++目录 -》包含文件，添加：D:\my_codes\curl-7.21.6\curl-7.21.6\include<br />
给项目添加依赖库：libcurl_imp.lib<br />
把libcurl.dll　拷到项目目录下。<br />
OK</p>
<p>然后，不爽，因为发布程序时要带上dll文件，决定用lib.<br />
然后老是出现<br />
1&gt;curl_adapter.obj : error LNK2001: 无法解析的外部符号 _curl_easy_setopt<br />
1&gt;curl_adapter.obj : error LNK2001: 无法解析的外部符号 _curl_easy_perform<br />
1&gt;curl_adapter.obj : error LNK2001: 无法解析的外部符号 _curl_easy_cleanup<br />
1&gt;curl_adapter.obj : error LNK2001: 无法解析的外部符号 _curl_easy_init<br />
1&gt;my_scrobbler.obj : error LNK2001: 无法解析的外部符号 _curl_free<br />
1&gt;my_scrobbler.obj : error LNK2001: 无法解析的外部符号 _curl_escape</p>
<p>找到原因：</p>
<p>http://blog.csdn.net/pgmsoul/archive/2009/05/20/4203941.aspx</p>
<p>http://curl.haxx.se/mail/lib-2007-11/0300.html</p>
<p>步骤：<br />
先确定项目的<br />
VS2008，项目——属性——配置属性——C/C++——代码生成：他有/MT，/MTd，/Md，/MDd四个选项<br />
要确定两个项目是一致的： libcurl 及 你自己的项目。</p>
<p>然后重新生成libcurl</p>
<p>然后到你的项目中：<br />
添加依赖库：<br />
#pragma comment( lib, &#8220;libcurl.lib&#8221; )<br />
#pragma comment ( lib, &#8220;ws2_32.lib&#8221; )<br />
#pragma comment ( lib, &#8220;winmm.lib&#8221; )<br />
#pragma comment (lib, &#8220;wldap32.lib&#8221;)</p>
<p>然后添加预处理器定义：【项目属性-》C/C++ -》 预处理器-》 预处理器定义】<br />
CURL_STATICLIB</p>
<p>重新编译OK!!!</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=526</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VC++ 编译libcurl 支持SSL,GZIP</title>
		<link>https://www.softwareace.cn/?p=525</link>
		<comments>https://www.softwareace.cn/?p=525#comments</comments>
		<pubDate>Thu, 15 Aug 2013 10:10:36 +0000</pubDate>
		<dc:creator><![CDATA[admin]]></dc:creator>
				<category><![CDATA[开源项目]]></category>
		<category><![CDATA[curl]]></category>

		<guid isPermaLink="false">http://www.softwareace.cn/?p=525</guid>
		<description><![CDATA[由于网上下载的 libcurl 不支持 gzip，只好自己动手编译，期间走了很多弯路，下面是最终成功的记录。  [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>由于网上下载的 libcurl 不支持 gzip，只好自己动手编译，期间走了很多弯路，下面是最终成功的记录。</p>
<p>我所使用的环境 Visual Studio 2010 、 Windows 7 64 bit</p>
<p><strong>1 下载文件</strong></p>
<p><strong>1.1 libcurl</strong></p>
<p>下载页面<a href="http://curl.haxx.se/download.html"> http://curl.haxx.se/download.html</a></p>
<p>下载地址 http://curl.haxx.se/download/curl-7.26.0.zip</p>
<p>&nbsp;</p>
<p><strong>1.2 zlib</strong></p>
<p>下载页面<a href="http://zlib.net/"> http://sourceforge.net/projects/libpng/files/zlib/</a></p>
<p>下载地址 http://sourceforge.net/projects/libpng/files/zlib/1.2.5/zlib125.zip/download</p>
<p><strong>（特别提醒，不要使用1.2.7版编译，使用后发现编译的方法和文件名都不同了）</strong></p>
<p>&nbsp;</p>
<p><strong>1.3 openssl</strong></p>
<p>下载页面<a href="http://www.openssl.org/source/"> http://www.openssl.org/source/</a></p>
<p>下载地址<a href="http://www.openssl.org/source/openssl-1.0.0c.tar.gz"> http://www.openssl.org/source/openssl-1.0.0c.tar.gz</a></p>
<p><strong>(特别提醒，不建议用1.0.1c，虽可编译成功，但无法绕过SSL证书，不知其原因，浪费了我不少时间)</strong></p>
<p>&nbsp;</p>
<p>编译openssl还需下载ActivePerl</p>
<p>官方下载<a href="http://www.activestate.com/activeperl/downloads"> http://www.activestate.com/activeperl/downloads</a></p>
<p>&nbsp;</p>
<p>下载地址：http://downloads.activestate.com/ActivePerl/releases/5.16.0.1600/ActivePerl-5.16.0.1600-MSWin32-x86-295879.msi</p>
<p>X64下载地址：http://downloads.activestate.com/ActivePerl/releases/5.16.0.1600/ActivePerl-5.16.0.1600-MSWin32-x64-295879.msi</p>
<p>&nbsp;</p>
<p><strong>2 解压及安装文件</strong></p>
<p>2.1 ActivePerl安装，双击直接下一步，默认设置到底。</p>
<p>2.2 zlib openssl libcurl分别解压，他们三个在同一级目录。</p>
<p>例如：D:\User\Dewei\TestCurl\curl-7.26.0、D:\User\Dewei\TestCurl\openssl-1.0.0c、D:\User\Dewei\TestCurl\zlib-1.2.5</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><strong>3 编译过程</strong></p>
<p>3.1 zlib编译</p>
<p>用vs2010打开zlib-1.2.5/old/visualc6/zlib.dsw，选择DLL_Release编译，把编译生成的zlib-1.2.5/old/visualc6/Win32_DLL_Release/ zlib1.lib 复制到curl-7.26.0/lib目录下，重命名为 zdll.lib （注意必须为此文件名） 。</p>
<p>&nbsp;</p>
<p>3.2 openssl编译</p>
<p>打开cmd，cd到openssl-1.0.0c目录下；</p>
<p>运行命令 perl Configure VC-WIN32</p>
<p>再运行   ms\do_ms.bat</p>
<p>再运行 &#8220;C:\Program Files (x86)\Microsoft Visual Studio 10.0\vcvars32.bat&#8221;</p>
<p>运行命令 nmake -f ms/ntdll.mak</p>
<p>&nbsp;</p>
<p>参考资料：openssl-1.0.0c/INSTALL.W32</p>
<p>&nbsp;</p>
<p>3.3 编译curl-7.26.0</p>
<p>在curl-7.26.0/lib目录下新建release.bat,输入以下内容</p>
<p>call &#8220;C:/Program Files/Microsoft Visual Studio 10.0/VC/bin/vcvars32.bat&#8221;<br />
set CFG=release-dll-ssl-dll-zlib-dll<br />
set OPENSSL_PATH=../../openssl-1.0.0c<br />
set ZLIB_PATH=../../zlib-1.2.5<br />
nmake -f Makefile.vc10</p>
<p>&nbsp;</p>
<p>保存，然后运行。</p>
<p>等待一会儿，就可以到 curl-7.26.0\lib\release-dll-ssl-dll-zlib-dll 目录下拷文件 libcurl_imp.lib和libcurl.dll 啦！</p>
<p>参考资料：curl-7.26.0/docs/INSTALL</p><pre class="crayon-plain-tag">Usage: nmake /f makefile.vc6 CFG=&lt;config&gt; &lt;target&gt;
where &lt;config&gt; is one of:
release                      - release static library
release-ssl                  - release static library with ssl
release-zlib                 - release static library with zlib
release-ssl-zlib             - release static library with ssl and zlib
release-ssl-ssh2-zlib        - release static library with ssl, ssh2 and zlib
release-ssl-dll              - release static library with dynamic ssl
release-zlib-dll             - release static library with dynamic zlib
release-ssl-dll-zlib-dll     - release static library with dynamic ssl and dynam
ic zlib
release-dll                  - release dynamic library
release-dll-ssl-dll          - release dynamic library with dynamic ssl
release-dll-zlib-dll         - release dynamic library with dynamic zlib
release-dll-ssl-dll-zlib-dll - release dynamic library with dynamic ssl and dyna
mic zlib
debug                        - debug static library
debug-ssl                    - debug static library with ssl
debug-zlib                   - debug static library with zlib
debug-ssl-zlib               - debug static library with ssl and zlib
debug-ssl-ssh2-zlib          - debug static library with ssl, ssh2 and zlib
debug-ssl-dll                - debug static library with dynamic ssl
debug-zlib-dll               - debug static library with dynamic zlib
debug-ssl-dll-zlib-dll       - debug static library with dynamic ssl and dynamic
 zlib
debug-dll                    - debug dynamic library
debug-dll-ssl-dll            - debug dynamic library with dynamic ssl
debug-dll-zlib-dll           - debug dynamic library with dynamic zlib1
debug-dll-ssl-dll-zlib-dll   - debug dynamic library with dynamic ssl and dynami
c zlib</pre><p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://www.softwareace.cn/?feed=rss2&#038;p=525</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
