第一步下载源代码,源代码有很多地方可以下载,此处从github下载
下载地址:
download zip
解压zip文件 ,进入winbuild目录
开始菜单--进入vs2019(或者其他版本)command prompt,如下
在此命令行下面,进入到curl源代码的winbuild目录,执行命令
参数说明如下:都可以在winbuild目录下的README.md文件中看到
## Build in the console
Once you are in the console, go to the winbuild directory in the Curl
sources:
cd curl-src\winbuild
Then you can call `nmake /f Makefile.vc` with the desired options (see
below). The builds will be in the top src directory, `builds\` directory, in
a directory named using the options given to the nmake call.
nmake /f Makefile.vc mode=<static or dll> <options>
where `<options>` is one or many of:
- `VC=<num>` - VC version. 6 or later.
- `WITH_DEVEL=<path>` - Paths for the development files (SSL, zlib, etc.)
Defaults to sibling directory: `../deps`
- `WITH_SSL=<dll/static>` - Enable OpenSSL support, DLL or static
- `WITH_NGHTTP2=<dll/static>` - Enable HTTP/2 support, DLL or static
- `WITH_MSH3=<dll/static>` - Enable (experimental) HTTP/3 support, DLL or static
- `WITH_MBEDTLS=<dll/static>` - Enable mbedTLS support, DLL or static
- `WITH_CARES=<dll/static>` - Enable c-ares support, DLL or static
- `WITH_ZLIB=<dll/static>` - Enable zlib support, DLL or static
- `WITH_SSH=<dll/static>` - Enable libSSH support, DLL or static
- `WITH_SSH2=<dll/static>` - Enable libSSH2 support, DLL or static
- `WITH_PREFIX=<dir>` - Where to install the build
- `ENABLE_SSPI=<yes/no>` - Enable SSPI support, defaults to yes
- `ENABLE_IPV6=<yes/no>` - Enable IPv6, defaults to yes
- `ENABLE_IDN=<yes or no>` - Enable use of Windows IDN APIs, defaults to yes
Requires Windows Vista or later
- `ENABLE_SCHANNEL=<yes/no>` - Enable native Windows SSL support, defaults
to yes if SSPI and no other SSL library
- `ENABLE_OPENSSL_AUTO_LOAD_CONFIG=<yes/no>`
- Enable loading OpenSSL configuration
automatically, defaults to yes
- `ENABLE_UNICODE=<yes/no>` - Enable UNICODE support, defaults to no
- `GEN_PDB=<yes/no>` - Generate External Program Database
(debug symbols for release build)
- `DEBUG=<yes/no>` - Debug builds
- `MACHINE=<x86/x64/arm64>` - Target architecture (default is x86)
- `CARES_PATH=<path>` - Custom path for c-ares
- `MBEDTLS_PATH=<path>` - Custom path for mbedTLS
- `NGHTTP2_PATH=<path>` - Custom path for nghttp2
- `MSH3_PATH=<path>` - Custom path for msh3
- `SSH2_PATH=<path>` - Custom path for libSSH2
- `SSL_PATH=<path>` - Custom path for OpenSSL
- `ZLIB_PATH=<path>` - Custom path for zlib
VC版本和VS版本的对应关系如下:有两种说法
比如装了vs2019,可以执行
nmake /f Makefile.vc mode=dll VC=16 MACHINE=x64
MACHINE代表当前电脑的系统版本,填写不对则会报错。
执行命令完成后,成功得到如下文件:
代表编译libcurl完成,libcurl 还可以集成很多库,比如说zlib,openssl等等,大家如果有需要可以自行再去研究。