windows下编译libcurl

该文详细介绍了如何在VisualStudio2019环境下下载curl的源代码,使用nmake和Makefile.vc进行编译,包括设置不同的选项如DLL或静态库,以及涉及到的依赖库如OpenSSL和zlib的配置。通过一系列命令行操作,最终成功编译生成libcurl库。
摘要由CSDN通过智能技术生成
  1. 第一步下载源代码,源代码有很多地方可以下载,此处从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等等,大家如果有需要可以自行再去研究。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

编程经验随笔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值