在 Windows 上使用 Visual Studio 编译 CURL

简介:

导语:

  • 教你科学地编译 Windows 版本的 libcurl (使用Windows SSPI或者OpenSSL)

准备工具

  • CMake (3.4.0)
  • Zlib (1.2.8)
  • libcurl (7.45.0)
  • OpenSSL (1.0.2d)
  • Visual Studio 2015

目标

  • 得到可以使用的 libcurl 静态库

步骤

  • 编译Zlib

    打开CMake,把 Zlib 目录下的 CMakeList.txt 拖进去,生成解决方案,这一步不能用 contrib\vstudio 下的 sln,里面的坑不少,尤其是低版本转高版本,生成解决方案后用VS打开,然后编译 Zlib 的静态库。

  • 编译 OpenSSL (如果用 SSPI 可略过这步)

    1. 装一个32位的Perl
    2. perl Configure VC-WIN32 no-asm --prefix:安装目录
    3. ms\do_nasm
    4. nmake -f ms\nt.mak -a
    5. nmake -f ms\nt.mak install
  • 编译 libcurl

    1. CMake 打开 CMakeList.txt
    2. Add Entry

      ZLIB_INCLUDE_DIR D:/developer/include/zlib

      ZLIB_LIBRARIES D:/developer/library/zlib

      OPENSSL_INCLUDE_DIR D:/developer/include

      OPENSSL_LIBRARIES D:/developer/library/openssl

    3. 注意勾选 Advanced 否则有可能失效

    4. Configure时,你要么用 OpenSSL,要么用Windows SSPI,如果你用 OpenSSL,在用 CMake 生成CURL的解决方案时,要把 CURL_WINDOWS_SSPI 这个选项的给去掉(要出现这个选项,需要勾选 CMake 的 Advanced),否则会出现结构重定义的问题,如果你不使用 OpenSSL,不传 OPENSSL_INCLUDE 和 OPENSSL_LIBRARIES 进去就好,然后把CMake里那个CMAKE_USE_OPENSSL的选项给去掉,不过前提是你是在编译Windows用的libcurl。

结束

  • 开启Visual Studio 2015 狂编译代码吧
相关文章
|
IDE 关系型数据库 开发工具
使用Visual Basic进行Windows窗体开发
【4月更文挑战第27天】本文介绍了使用Visual Basic进行Windows窗体(WinForms)开发的步骤,从搭建开发环境到创建、设计用户界面,再到编写事件驱动的代码和数据绑定。Visual Basic结合WinForms提供了一种易学易用的桌面应用开发方案。通过调试、优化、部署和维护,开发者可以构建专业应用程序。随着技术发展,掌握最新UI设计和开发工具对于保持竞争力至关重要。本文为初学者提供了基础指导,鼓励进一步探索和学习。
476 0
|
5月前
|
NoSQL IDE MongoDB
Studio 3T 2025.11 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.11 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
350 3
|
2月前
|
NoSQL IDE MongoDB
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
260 1
Studio 3T 2025.17 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
3月前
|
安全 Linux C++
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
174 0
PVS‑Studio 7.38 for macOS, Linux & Windows - 代码质量安全静态分析
|
5月前
|
NoSQL IDE MongoDB
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
436 21
Studio 3T 2025.10 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
6月前
|
安全 Linux iOS开发
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
141 1
PVS‑Studio 7.36 for macOS, Linux & Windows - 代码质量安全静态分析
|
关系型数据库 数据库 C++
【C++】Windows使用Visual Studio C++链接云数据库PostgreSQL(沉浸式老爷教学)
【C++】Windows使用Visual Studio C++链接云数据库PostgreSQL(沉浸式老爷教学)
|
8月前
|
NoSQL IDE MongoDB
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
325 2
Studio 3T 2025.5 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
8月前
|
NoSQL IDE MongoDB
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
321 0
Studio 3T 2025.4 (macOS, Linux, Windows) - MongoDB 的终极 GUI、IDE 和 客户端
|
C++ Python Windows
在Visual Studio中使用Python(Windows)
在Visual Studio中使用Python(Windows)
140 2