在windows 上编译 OpenSSL, zlib 和 cURL (转载)

全文转载:原网址:

How to Build OpenSSL, zlib, and cURL libraries on Windows | Refinitiv Developers

Author:

Jirapongse Phuriphanvichai

Developer Advocate

OpenSSL, zlib, and cURL are open-source computer software projects to secure communications over computer networks, compress data, and transfer data through various network protocols, respectively. The projects are comprised of command-line tools, header files, and libraries. They are widely used by many systems, applications, and libraries including Refinitiv Real-Time SDK C/C++. Users can utilize available OpenSSL, zlib, and cURL libraries available on the Internet or build the latest versions of those libraries from the source code.

Refinitiv Real-Time SDK C/C++ is a suite of modern and open-source APIs that is designed to simplify development through a strong focus on ease of use and standardized access to a broad set of Refinitiv and proprietary content and services. It uses these libraries to connect to encrypted servers or Refinitiv Real-Time Optimized on the cloud.

This article demonstrates step by step to build OpenSSL, zlib, and cURL libraries from the source code on a Windows machine (Windows 10). Then, it shows how to use these libraries in Refinitiv Real-Time SDK C/C++. The topics include:

  • Build OpenSSL Libraries
  • Build zlib libraries
  • Build cURL Libraries
  • Use the Libraries with Refinitiv Real-Time SDK C/C++

Prerequisites

To follow the steps in this article, you need to have a Windows 10 machine with the following applications installed.

  1. Microsoft Visual Studio: Desktop Development with C++ (such as, Visual Studio 2019 or 2022)
  2. Strawberry Perl: A perl environment for Microsoft Windows (Required to build OpenSSL)
  3. Netwide Assembler (NASM): An assembler for the x86 CPU architecture (Required to build OpenSSL)
  4. A decompression tool, such as WinRAR

Build OpenSSL Libraries

OpenSSL is a software library implementing the SSL and TLS protocols for applications that secure communications over computer networks. It is widely used by Internet servers, including the majority of HTTPS websites. It contains two libraries which are libssl and libcrypto. The libcrypto library provides the fundamental cryptographic routines used by libssl.

The following steps show how to build the OpenSSL libraries and a binary file from the OpenSSL source package on a Windows 10 machine.

1.      Download and decompress the OpenSSL source code package

The OpenSSL is open source and the source code is available on the OpenSSL official website (https://www.openssl.org). At the time of this writing, the current versions of the OpenSSL packages are openssl-1.1.1o and openssl-3.0.3.

I will download the openssl-1.1.1o package but the steps mentioned in this article can also be used with the openssl-3.0.3 package.

First, download the OpenSSL source package (openssl-1.1.1o.tar.gz) and decompress it to the local directory, such as C:\local\src.

2.      Configure the package

To follow this step, the Perl and NASM directory must be added to the Path environment variable.

You can test it my running “perl -v” and “nasm -v” on the command prompt.

 

perl -v

...

nasm -v

Copy

From the previous step, all files are extracted in the openssl-1.1.1.o directory. Run the x64 Native Tools Command Prompt for Visual Studio and then change the directory to C:\local\src\ openssl-1.1.1.o.

Then, run the config command to configure the OpenSSL source package. 

perl Configure VC-WIN64A --prefix=c:\local\openssl1.1.1Copy

I ran the Configure command with the following options.

Option Description
--prefix= c:\local\openssl1.1.1 The top of the installation directory tree. The OpenSSL libraries will be created in this directory (c:\local\openssl1.1.1)

For other options, please refer to the INSTALL file in the OpenSSL source package. 

正在上传…重新上传取消

3.      Build the OpenSSL libraries

Run the nmake command to build the OpenSSL libraries (libcrypto and libssl) and the OpenSSL binary (openssl). 

nmakeCopy

The libraries will be built in the top-level directory, and the binary will be in the apps subdirectory.

Finally, run the “nmake install” command to install OpenSSL on the machine. 

nmake installCopy

The command will install all the OpenSSL components in the directory specified in the --prefix option (C:\local\openssl1.1.1). OpenSSL configuration files are in the C:\Program Files\Common Files\SSL directory.

The libraries are in the C:\local\openssl1.1.1\lib and C:\local\openssl1.1.1\bin directory and the OpenSSL binary file is in the C:\local\openssl1.1.1\bin directory. 

At this point, the OpenSSL binary and library files are built properly. 

Build zlib Libraries

Zlib is a free and general-purpose lossless data-compression software library for use on any computer hardware and software platform, including Linux, macOS, and Windows. The zlib data format is itself portable across platforms. The following steps demonstrate how to build zlib libraries from the zlib source package on a Windows 10 machine.

1.      Download and decompress the zlib source code package

Zlib is open source and the source code is available on the zlib official website (zlib Home Site). At the time of this writing, the current version of the zlib package is zlib-1.2.12. Download the zlib source package (zlib-1.2.12.tar.gz) and decompress it to the local directory, such as C:\local\src.

正在上传…重新上传取消

2.      Build the zlib libraries

From the previous step, all files are extracted in the zlib-1.2.12 directory. Run the x64 Native Tools Command Prompt for Visual Studio and then change the directory to C:\local\src\zlib-1.2.12.

正在上传…重新上传取消

Then, run the nmake command to build the zlib libraries. 

nmake /f win32/Makefile.mscCopy

The following files will be created in the C:\local\src\zlib-1.2.12 directory.

  • zlib.lib: A zlib static library
  • zlib.pdb: A program database file of zlib.lib       
  • zdll.lib:  An import library of zlib1.dll
  • zlib1.dll: A zlib shared library
  • zlib1.pdb: A program database of zlib1.dll       

3.      Copy zlib files

In this step, the zlib header files and library files will be copied to the new zlib folder. First, create a new folder for zlib files, such as C:\local\zlib

Then, copy zlib.h and zconf.h files from C:\local\src\zlib-1.2.12 to C:\local\zlib\include

Finally, copy the zlib library files from C:\local\src\zlib-1.2.12 to C:\local\zlib\lib directory.

At this point, the zlib library files are built properly. 

Build cURL Library

cURL is a computer software project providing a library and a command-line tool for transferring data using various network protocols. It builds and works identically on many platforms. cURL supports HTTPS and performs SSL certificate verification by default when a secure protocol is specified such as HTTPS. It relies on the OpenSSL libraries to perform SSL certificate verification.

The following steps show how to build a cURL library and cURL binary file from the cURL source package on a Windows 10 machine. Moreover, the cURL library and cURL binary file will use the zlib and OpenSSL libraries created in the previous sections.

1.      Download and decompress the cURL source code package

cURL is open source and the source code is available on the cURL official website (https://curl.se/download.html). At the time of this writing, the current version of the cURL package is curl-7.83.1.

First, download the cURL source package (curl-7.83.1.tar.gz) and decompress it to the local directory, such as C:\local\src.

2.      Build the cURL libraries

From the previous step, all files are extracted in the curl-7.83.1 directory. Run the x64 Native Tools Command Prompt for Visual Studio and then change the directory to C:\local\src\curl-7.83.1\winbuild.

cURL supports many underlying protocols. We can configure it when building the libraries. The following section demonstrates the ways to build the cURL libraries that support Schannel and OpenSSL, respectively. 

2.1  Build the cURL libraries that use Schannel and zlib

The Microsoft Secure Channel (Schannel) is a security package that facilitates the use of Secure Sockets Layer (SSL) and/or Transport Layer Security (TLS) encryption on Windows platforms. Schannel will use certificates from the Windows certificate store.

Run the following nmake command to build the cURL libraries and the cURL binary that use Schannel and zlib. 

nmake /f Makefile.vc mode=dll MACHINE=x64 WITH_ZLIB=dll ZLIB_PATH=C:\local\zlibCopy

I ran the nmake command with the following options.

Option Description
mode=dll Build a cURL dynamic library
MACHINE=x64 Target architecture (default is x86)
WITH_ZLIB=dll  Enable zlib support, DLL or static
ZLIB_PATH=C:\local\zlib Custom path for zlib (C:\local\zlib)

cURL files are built in the .\builds\libcurl-vc-x64-release-dll-zlib-dll-ipv6-sspi-schannel directory.

The cURL and DLL files are in the bin directory.

2.2  Build the cURL libraries that use OpenSSL and zlib

cURL can be built to support OpenSSL. Run the following nmake command to build the cURL libraries and the cURL binary that use OpenSSL and zlib.

nmake /f Makefile.vc mode=dll MACHINE=x64 WITH_SSL=dll SSL_PATH=C:\local\openssl1.1.1 WITH_ZLIB=dll ZLIB_PATH=C:\local\zlibCopy

I ran the nmake command with the following options.

Option Description
mode=dll Build a cURL dynamic library
MACHINE=x64 Target architecture (default is x86)
WITH_SSL=dll Enable OpenSSL support, DLL or static
SSL_PATH=C:\local\openssl1.1.1 Custom path for OpenSSL (C:\local\openssl1.1.1)
WITH_ZLIB=dll  Enable zlib support, DLL or static
ZLIB_PATH=C:\local\zlib Custom path for zlib (C:\local\zlib)

cURL files are built in the .\builds\libcurl-vc-x64-release-dll-ssl-dll-zlib-dll-ipv6-sspi directory.

The cURL and DLL files are in the bin directory.

For other options, please refer to the README.md file in the winbuild directory. 

At this point, the cURL binary and library files are built properly. 

Use the Libraries with Refinitiv Real-Time SDK C/C++

The OpenSSL, zlib, and cURL can be used with the Refinitiv Real-Time SDK C/C++ applications to connect to encrypted servers or Refinitiv Real-Time Optimized on the cloud. Refinitiv Real-Time SDK C/C++ on Windows uses libcurl that supports Schannel.  

1.      Copy the following files to the current directory of the Refinitiv Real-Time SDK C/C++ application.

  • C:\local\zlib\lib\zlib1.dll
  • C:\local\openssl1.1.1\bin\libcrypto-1_1-x64.dll
  • C:\local\openssl1.1.1\bin\libssl-1_1-x64.dll
  • C:\local\src\curl-7.83.1\builds\libcurl-vc-x64-release-dll-zlib-dll-ipv6-sspi-schannel\bin\libcurl.dll

2.      Run the application. The application loads the OpenSSL, zlib, and cURL libraries found in the working directory and then connects to an encrypted server on Refinitiv Real-Time Optimized.

Summary

OpenSSL, zlib, and cURL are open-source and popular software projects used to secure communications over computer networks, compress data, and transfer data through various network protocols. Users can easily build the binary packages from the project’s source code. With this method, users can get the latest version of the packages. This article demonstrates step by step to build OpenSSL, zlib, and curl libraries from the source code on a Windows 10 machine. There are a few steps to building the package. The first step is downloading the source code package from the official project website. The second step is decompressing the package. The third step is configuring the package and the final step is building the package. The outcome contains executable files, development libraries, and header files.

References

1.      cURL. n.d. cURL. [online] Available at: <curl> [Accessed 3 May 2022].

2.      En.wikipedia.org. n.d. cURL - Wikipedia. [online] Available at: <https://en.wikipedia.org/wiki/CURL> [Accessed 3 May 2022].

3.      OpenSSL. n.d. OpenSSL. [online] Available at: </index.html> [Accessed 3 May 2022].

4.      En.wikipedia.org. n.d. OpenSSL - Wikipedia. [online] Available at: <https://en.wikipedia.org/wiki/OpenSSL> [Accessed 3 May 2022].

5.      Developers.refinitiv.com. n.d. Refinitiv Real-Time C++ SDK | Refinitiv Developers. [online] Available at: <Refinitiv Real-Time C++ SDK | Refinitiv Developers> [Accessed 3 May 2022].

6.      En.wikipedia.org. n.d. zlib - Wikipedia. [online] Available at: <https://en.wikipedia.org/wiki/Zlib> [Accessed 11 May 2022].

7.      Zlib.net. n.d. zlib Home Site. [online] Available at: <zlib Home Site> [Accessed 11 May 2022].

8.      Bacon, M., n.d. What is Microsoft Schannel (Microsoft Secure Channel)? - Definition from WhatIs.com. [online] TechTarget. Available at: <What is Microsoft Schannel (Microsoft Secure Channel)? - Definition from WhatIs.com> [Accessed 24 May 2022].

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


学习编程是顺着互联网的发展潮流,是一件好事。新手如何学习编程?其实不难,不过在学习编程之前你得先了解你的目的是什么?这个很重要,因为目的决定你的发展方向、决定你的发展速度。
IT行业是什么工作做什么?IT行业的工作有:产品策划类、页面设计类、前端与移动、开发与测试、营销推广类、数据运营类、运营维护类、游戏相关类等,根据不同的分类下面有细分了不同的岗位。
女生学Java好就业吗?女生适合学Java编程吗?目前有不少女生学习Java开发,但要结合自身的情况,先了解自己适不适合去学习Java,不要盲目的选择不适合自己的Java培训班进行学习。只要肯下功夫钻研,多看、多想、多练
Can’t connect to local MySQL server through socket \'/var/lib/mysql/mysql.sock问题 1.进入mysql路径
oracle基本命令 一、登录操作 1.管理员登录 # 管理员登录 sqlplus / as sysdba 2.普通用户登录
一、背景 因为项目中需要通北京网络,所以需要连vpn,但是服务器有时候会断掉,所以写个shell脚本每五分钟去判断是否连接,于是就有下面的shell脚本。
BETWEEN 操作符选取介于两个值之间的数据范围内的值。这些值可以是数值、文本或者日期。
假如你已经使用过苹果开发者中心上架app,你肯定知道在苹果开发者中心的web界面,无法直接提交ipa文件,而是需要使用第三方工具,将ipa文件上传到构建版本,开...
下面的 SQL 语句指定了两个别名,一个是 name 列的别名,一个是 country 列的别名。**提示:**如果列名称包含空格,要求使用双引号或方括号:
在使用H5混合开发的app打包后,需要将ipa文件上传到appstore进行发布,就需要去苹果开发者中心进行发布。​
+----+--------------+---------------------------+-------+---------+
数组的声明并不是声明一个个单独的变量,比如 number0、number1、...、number99,而是声明一个数组变量,比如 numbers,然后使用 nu...
第一步:到appuploader官网下载辅助工具和iCloud驱动,使用前面创建的AppID登录。
如需删除表中的列,请使用下面的语法(请注意,某些数据库系统不允许这种在数据库表中删除列的方式):
前不久在制作win11pe,制作了一版,1.26GB,太大了,不满意,想再裁剪下,发现这次dism mount正常,commit或discard巨慢,以前都很快...
赛门铁克各个版本概览:https://knowledge.broadcom.com/external/article?legacyId=tech163829
实测Python 3.6.6用pip 21.3.1,再高就报错了,Python 3.10.7用pip 22.3.1是可以的
Broadcom Corporation (博通公司,股票代号AVGO)是全球领先的有线和无线通信半导体公司。其产品实现向家庭、 办公室和移动环境以及在这些环境...
发现个问题,server2016上安装了c4d这些版本,低版本的正常显示窗格,但红色圈出的高版本c4d打开后不显示窗格,
TAT:https://cloud.tencent.com/document/product/1340