MinGW 32bit构建Curl with Openssl流程

前言

目前网络上许多构建Curl和OpenSSL的教程都是很老的,并且大多数教程都是针对VS IDE进行构建。对于MinGW版本的Curl库构建,资料都很少。我从网络资料得到启发,根据项目中的指引,最终将MinGW版本的Curl和OpenSSL都构建了出来,在此记录当作备份和交流

实战

资料准备

环境准备

配置工具

  1. 安装Msys1.0【建议遵循默认设定安装到C盘中】,后续操作全部都在Msys中完成,不使用Win的CMD终端。
  2. 解压MinGW版本Perl到空闲目录
  3. 完成后打开msys.bat进入Msys环境,通过命令cat /etc/fstab查看开机自动挂载点的情况:
67566@BEN-WORKPC ~
$ cat /etc/fstab
#fstab.sample
#This is a sample file for /etc/fstab.
#Currently /etc/fstab is only read during dll initialization.
#I will eventually watch the directory for changes and reread the file.
#The line format is simple in that you give the Win32 path, followed by one or
#more space or tab delimiter, followed by the mount point.  Mount points in
#typical UNIX environments must be a physical name on a drive before it can
#actually be used as a mount point.  In this implementation the "must exist"
#requirement isn't enforced, however, it will be an aide to such programs as
#find and readline's tab completion if it does exist.

#You can use a # as the first character on the line as a comment indicator.
#Blank lines are ignored.

#Win32_Path                                                             Mount_Point
c:\\Qt\\Qt5.12.12\\Tools\\mingw730_32                                  /mingw
c:\\Users\\67566\\Downloads\\perl-5.24.0-mingw32\\perl-5.24.0          /perl

可以看到我分别将我对应Win盘符中的MinGW和MinGW版本的Perl路径挂载到了对应挂载点上

  • c:\Qt\Qt5.12.12\Tools\mingw730_32
  • c:\Users\67566\Downloads\perl-5.24.0-mingw32\perl-5.24.0

挂载点有两个:

  • mingw
  • perl

你需要将自己的MinGW和MinGW版本的Perl路径对应挂载上去

  1. 重新打开Msys环境,确认mingw32-make指令和perl指令可用,并且通过-v查看版本也对应的上

配置项目路径

将Curl源码包和OpenSSL源码包放置到Msys的home目录,确保进入这两个文件夹后,就是项目文件,而不是还有额外的子文件夹,以便后期进行构建工作
在这里插入图片描述

构建OpenSSL

  1. 在Msys环境中,进入OpenSSL项目文件夹
  2. 执行
    • perl Configure mingw shared no-asm【构建动态库】
    • perl Configure mingw no-shared no-asm【构建静态库】

这个操作会生成Makefile文件

  1. 修改Makefile中的此部分内容成以下格式,原先使用的是Win规则的路径,会导致构建出错
    在这里插入图片描述
  2. 在OpenSSL项目文件夹,直接执行mingw32-make,构建OpenSSL所需库。构建完成后会得到以下文件【以动态库为例】:
    • libssl.a 静态库
    • libssl.dll.a 动态导入库
    • libssl-x.dll 动态库,其中x会变成OpenSSL的大版本,比如libssl-3.dll
    • libcrypto.a
    • libcrypto.dll.a
    • libcrypto-x.dll
  3. 在OpenSSL根目录新建out文件夹,将libssl.dll.a和libcrypto.dll.a分别改为libssl32.dll和libeay32.dll,放置到out文件夹中;同时新建outinc文件夹,将include文件夹中的内容复制到outinc。以便Curl项目能读取到OpenSSL的头文件及动态导入库

注意:老版本的OpenSSL库名称为libeay,libssl之类的,最新版的库已经更换名字

构建Curl

  1. 进入Curl项目目录
  2. 进入lib文件夹,修改Makefile.m32文件中的以下内容,进行OpenSSL路径的配置
    在这里插入图片描述
  3. 构建curl,有两种方法:
  • 在Curl项目根目录,执行mingw32-make mingw32-ssl
  • 在Curl项目的lib目录,执行mingw32-make -f Makefile.m32 CFG=-ssl
  1. 构建成功后会生成:
  • libcurl.a
  • libcurl.dll.a
  • libcurl.dll
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值