Curl的编译

下载

curl的官网:https://curl.haxx.se/

libcurl就是一个库,curl就是使用libcurl实现的。

curl是一个exe,也可以说是整个项目的名字,而libcurl就是一个独立的库,所以做二次开发一般就使用库,当然为了简单也可以直接用curl.exe来完成。

curl只提供了源码的方式:https://curl.haxx.se/download.html,其他的方式都是第三方自己编译发布的。

curl下载安装的方式参考:https://curl.haxx.se/dlwiz/

curl executable - You will get a pre-built 'curl' binary from this link (or in some cases, by using the information that is provided at the page this link takes you). You may or may not get 'libcurl' installed as a shared library/DLL.
libcurl development - This is for libcurl development - but does not always contain libcurl itself. Most likely header files and documentation. If you intend to compile or build something that uses libcurl, this is most likely the package you want.
libcurl - This is a pure binary libcurl package, possibly including header files and documentation, but without the command line tool and other cruft. If you want libcurl for a program that uses libcurl, this is most likely the package you want.
source code - You will not download a pre-built binary from this link. You will instead get a link to site with the curl source, adjusted for your platform. You will need to have a compiler setup and working to be able to build curl from a source package.
Show All - Display all known package types.
这里的下载方式多数也是其他商家提供的,除了源码和可执行程序以外。

比如libcurl dev就没有windows平台的。

比如libcurl就是cygwin提供的,所以他的库也是用于cygwin的。

而sourcecode就可以下载平台独立的包,但是不是最新的。所以直接在https://curl.haxx.se/download.html页面下载即可。

下面就是主页下载的图片:

Curl的编译_第1张图片

我们就下载zip版本:

clipboard[1]

官方资料

https://curl.haxx.se/libcurl/c/

https://curl.haxx.se/libcurl/c/libcurl-tutorial.html

其他的HTTPClient

libcurl (MIT)

  • a highly portable and easy-to-use client-side URL transfer library, supporting DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP. libcurl also supports HTTPS certificates, HTTP POST, HTTP PUT, FTP uploading, kerberos, HTTP form based upload, proxies, cookies, user+password authentication, file transfer resume, http proxy tunnelling and more!

libghttp (LGPL)

  • Having a glance at libghttp (a gnome http library), it looks as if it works rather similar to libcurl (for http). There's no web page for this and the person who's email is mentioned in the README of the latest release I found claims he has passed the leadership of the project to "eazel". Popular choice among GNOME projects.
libwww ( W3C license) comparison with libcurl
  • More complex and harder to use than libcurl is. Includes everything from multi-threading to HTML parsing. The most notable transfer-related feature that libcurl does not offer but libwww does, is caching.
libferit (GPL)
  • C++ library "for transferring files via http, ftp, gopher, proxy server". Based on 'snarf' 2.0.9-code (formerly known as libsnarf). Quote from freshmeat: "As the author of snarf, I have to say this frightens me. Snarf's networking system is far from robust and complete. It's probably full of bugs, and although it works for maybe 85% of all current situations, I wouldn't base a library on it."
neon (LGPL) comparison with neon
  • An HTTP and WebDAV client library, with a C interface. I've mainly heard and seen people use this with WebDAV as their main interest. This is one of the two alternatives used by the Subversion project.
libsoup (LGPL) comparison with libcurl
  • Part of glib (GNOME). Supports: HTTP 1.1, Persistent connections, Asynchronous DNS and transfers, Connection cache, Redirects, Basic, Digest, NTLM authentication, SSL with GnuTLS, Proxy support including SSL, POST data. Not portable. Lacks: cookie support, NTLM for proxies, GSS, gzip encoding, trailers in chunked responses, portability and more.
mozilla netlib (MPL)
  • Handles URLs, protocols, transports for the Mozilla browser.
mozilla libxpnet (MPL)
  • Minimal download library targeted to be much smaller than the above mentioned netlib. HTTP and FTP support.
wget (GPL)
  • While not a library at all, I've been told that people sometimes extract the network code from it and base their own hacks from there.
libfetch (BSD)
  • Does HTTP and FTP transfers (both ways), supports file: URLs, and an API for URL parsing. The utility fetchthat is built on libfetch is an integral part of the FreeBSD operating system.
HTTP Fetcher (LGPL)
  • " a small, robust, flexible library for downloading files via HTTP using the GET method."
http-tiny (Artistic License)
  • " a very small C library to make http queries (GET, HEAD, PUT, DELETE, etc.) easily portable and embeddable"
wininet comparison with libcurl
  • "The Windows Internet (WinINet) application programming interface (API) enables applications to interact with Gopher, FTP, and HTTP protocols to access Internet resources."
XMLHTTP Object also known as IXMLHTTPRequest (part of MSXML 3.0)
  • (Windows) Provides client-side protocol support for communication with HTTP servers. A client computer can use the XMLHTTP object to send an arbitrary HTTP request, receive the response, and have the Microsoft® XML Document Object Model (DOM) parse that response.
QHttp (GPL)
  • QHttp is a class in the Qt library from Troll Tech. Seems to be restricted to plain HTTP. Supports GET, POST and proxy. Asynchronous.
ftplib (GPL)
  • " a set of routines that implement the FTP protocol. They allow applications to create and access remote files through function calls instead of needing to fork and exec an interactive ftp client program."
    I stopped using it because it did not evolve and the maintainer did not even answer to my e-mailed patches and forum posts. The web site seems abandoned and the forum is not reachable anymore. It is simpler to use than libcurl, because it is not based on callbacks. But is is also much less powerful. / Patrick
ftplib++ (GPL)
  • A C++ library for "easy FTP client functionality. It features resuming of up- and downloads, FXP support, SSL/TLS encryption, and logging functionality."
GNU Common C++ library
  • Has a URLStream class. This C++ class allow you to download a file using HTTP. See demo/urlfetch.cpp in commoncpp2-1.3.19.tar.gz
HTTPClient (LGPL)
  • Java HTTP client library.
Jakarta Commons HttpClient (Apache License)
  • A Java HTTP client library written by the Jakarta project.
gnetlibrary (LGPL)
  • "a simple network library. It is written in C, object-oriented, and built upon GLib. It is intended to be easy to use and port". Features a HTTP component. It uses glib, and integrates very well within Gtk+ applications, which require event-driven programming.
Serf (Apache License)
  • "The serf library is a C-based HTTP client library built upon the Apache Portable Runtime (APR) library. It multiplexes connections, running the read/write communication asynchronously." This is one of the two alternatives used by the Subversion project.
qDecoder (BSD)
  • qDecoder is a development kit for C/C++ network programming includes simple HTTP client API.

 

 

编译

在curl的官方文档里面没有看到readme有讲解怎么使用,编译,安装等。但是肯目录结构也能猜出来...

就是在projects下面就有使用IDE编译的说明。还有一种编译方式,直接用命令的方式,参考:curl-7.50.1\winbuild

1.先用generate.bat生成项目文件

Curl的编译_第2张图片

2.下载依赖库

下载的依赖库最好都应该放到同一个目录,跟curl是同一级的目录

1)    activeperl

        下载地址:http://www.activestate.com/activeperl/downloads

Curl的编译_第3张图片

2)    openssl

“openssl/ssl.h”: No such file or directory

https://www.openssl.org/source/

Curl的编译_第4张图片

        参考文件:INSTALL.W32

        1.配置:openssl-1.0.2h>perl Configure VC-WIN32 --prefix=E:\openssl (我们不需要汇编asm,所以不用这个方案)

perl Configure VC-WIN32 no-asm --prefix=E:/openssl/

        2.ms\do_nasm(我们不需要汇编asm,所以不用这个方案)

ms\do_ms

        3.换用vs的命令行工具,切换到根目录,然后,输入:nmake -f ms\ntdll.mak

Curl的编译_第5张图片

Curl的编译_第6张图片

错误:

cryptlib.obj : error LNK2001: 无法解析的外部符号 _OPENSSL_ia32cap_P

        cryptlib.obj : error LNK2019: 无法解析的外部符号 _OPENSSL_ia32_cpuid,该符号在函数 _OPENSSL_cpuid_setup 中被引用

        这个错误的原因是之前编译的临时文件没有清理的问题,因为我之前编译的时候没有添加no-asm选项,后面加上时没有清理就直接编译了,那肯定有问题。

        所以重新清理下再编译即可(清理方式就是重新解压一份原来的压缩包,重新来就是了)

        4.测试

nmake -f ms\ntdll.mak test

Curl的编译_第7张图片

        5.安装

nmake -f ms\ntdll.mak install

Curl的编译_第8张图片

            安装完成之后就是如下目录:

Curl的编译_第9张图片

3)    Zlib

http://zlib.net/

http://zlib.net/zlib128.zip

clipboard[14]

        zlib需要用makefile(zlib128\zlib-1.2.8\win32)编译(或者用VS也可以:zlib128\zlib-1.2.8\contrib\vstudio\vc10)

        用makefile就需要启动VS的命令提示符来进行编译:

Curl的编译_第10张图片

        切换到zlib目录,然后输入nmake -f win32/Makefile.msc

Curl的编译_第11张图片

        下面是编译完成之后的截图:

Curl的编译_第12张图片

4)    libssh2

        下载地址:https://www.libssh2.org/download/libssh2-1.7.0.tar.gz

        打开:libssh2-1.7.0\win32\libssh2.dsw

Curl的编译_第13张图片

clipboard[19]

5)    pthread

        ftp://sourceware.org/pub/pthreads-win32/pthreads-w32-2-9-1-release.zip

        这是一家编译好的版本,直接用就是了

3.使用VS编译Curl

在project下面,根据自己的VS版本类型,选择对应的目录进去即可。

Curl的编译_第14张图片

1)    配置libcurl依赖库的头文件路径

Curl的编译_第15张图片

2)    配置libcurl库的lib路径

Curl的编译_第16张图片

3)    修改依赖的库

Curl的编译_第17张图片

        由于我们的VS环境可能已经配置了其他的默认的一些库,所以这里编译就可能导致依赖的不相关的库找不到。

        于是我们就不从父级继承,而是直接把kernel32.lib和user32.lib添加上即可

4)    生成libcurl

Curl的编译_第18张图片

5)    同样,修改curl的lib

Curl的编译_第19张图片

6)    生成curl

Curl的编译_第20张图片

Curl的编译_第21张图片

头文件路径

curl-7.50.1\include

你可能感兴趣的:(C++,curl,libcurl,openssl,libssh2)