windows + Mingw32-make 编译 PoDoFo库,openssl, libjpeg, Msys2工具的使用

参考:

https://blog.csdn.net/sspdfn/article/details/104244306

https://blog.csdn.net/yaoyuanyylyy/article/details/17436303

https://blog.csdn.net/wxlfreewind/article/details/106492253

前期进行了各种摸索,由于Podofo依赖库比较多,所依赖的库都需要编译为Mingw版本,参考以上三篇博客,因为环境原因一直出现各种问题,直到。。。发现了Msys2构建平台

** 想省事的同学可以直接下载编译好的版本 (32bit) **:https://download.csdn.net/download/wml00876/88498301

MSYS2 官网

下载与安装参考:
https://blog.csdn.net/qq_41898196/article/details/130102966
https://blog.csdn.net/B11050729/article/details/131719012

进入Mingw终端:

配置好环境后,打开目标终端,通过pacman指令安装Podofo的依赖库,部分指令如下:

cpp 复制代码
# pacman -S mingw-w64-i686-toolchain
# pacman -S  mingw-w64-i686-cmake-gui
# pacman -S	 mingw-w64-i686-cmake
# pacman -S mingw-w64-i686-libidn
# pacman -S  mingw-w64-i686-freetype
# pacman -S  mingw-w64-i686-libpng
# pacman -S  mingw-w64-i686-libtiff
# pacman -S  mingw-w64-i686-libxml2
# pacman -S  mingw-w64-i686-zlib
# pacman -S mingw-w64-i686-bzip2

如果需要其它库可以自行安装;


PoDoFo 官网GitHub


由于 pacman仓库中维护的开源库都是比较新的版本,openssl为3.x版本,所以podofo选择较新版本0.10.x

0.10.x以后才可支持openssl 3.0

运行事例时发现,podofo并不能支持pacman仓库中的openssl版本3.1.x,虽然可以编译构建,但在程序中调用pdf库时,会报错:
bash 复制代码
terminate called after throwing an instance of 'PoDoFo::PdfError'
  what():  PdfErrorCode::InvalidHandle, An invalid handle was passed or returned, but initialized data was expected.
Callstack:t#0 Error Source: main\PdfEncrypt.cpp(66), Information: Unable to load legacy providers in OpenSSL >= 3.x.x

编译Openssl 3.0.x版本(我选择的版本为3.0.12) 参考链接

在MakeFile目录中打开终端,执行命令:

shell 复制代码
$ mingw32-make.exe 
$ mingw32-make.exe install

成功后,openssl安装在以下目录:

编译libjpeg

pacman 仓库中有 mingw-w64-i686-libjpeg-turbo 3.0.1-1这个包,使用这个版本的jpeg库make时会报错:

shell 复制代码
: error: cannot convert 'PoDoFo::PdfIndirectObjectList' to 'HANDLE' {aka
'void*'}
  500 |         && (indirectobj = GetObject(*m_objects, ref)) != nullptr)
      |                                     ^~~~~~~~~~
      |                                     |
      |                                     PoDoFo::PdfIndirectObjectList

由于时间关系没有研究 mingw-w64-i686-libjpeg-turbo 3.0.1-1 与 jpep官网上的版本有何区别,所以直接在官网下载了 jpegsr9e 版本,进行编译:

Msys2终端进入解压目录,执行以下命令:

shell 复制代码
$ ./configure
$ mingw32-make.exe 
$ mingw32-make.exe install

完成后,相关文件直接安装到Msys2环境中,目录如下:


下载PODOFO源码:

下载源码后,解压到 Msys2环境中的home(其它目录也可以,根据个人习惯)

打开Cmake-gui

如果依赖库提前安装后,Cmake会自动读取到(openssl如果无法读取到,手动配置一下)

如果加载项目失败,考虑C:\msys64\mingw32\bin添加到系统环境变量中

可能第一次加载需要选择编译器

执行: configure 、Generate

遇到问题,查看配置项中的红色部分

终端进入build目录,执行:

powershell 复制代码
$ mingw32-make.exe 
$ mingw32-make.exe install

构建结束后,查看安装目录:

相关推荐
cpsvps_net15 小时前
美国服务器环境下Windows容器工作负载智能弹性伸缩
windows
甄超锋15 小时前
Java ArrayList的介绍及用法
java·windows·spring boot·python·spring·spring cloud·tomcat
cpsvps17 小时前
美国服务器环境下Windows容器工作负载基于指标的自动扩缩
windows
网硕互联的小客服20 小时前
Apache 如何支持SHTML(SSI)的配置方法
运维·服务器·网络·windows·php
etcix20 小时前
implement copy file content to clipboard on Windows
windows·stm32·单片机
许泽宇的技术分享21 小时前
Windows MCP.Net:基于.NET的Windows桌面自动化MCP服务器深度解析
windows·自动化·.net
非凡ghost1 天前
AMS PhotoMaster:全方位提升你的照片编辑体验
windows·学习·信息可视化·软件需求
mortimer1 天前
一次与“顽固”外部程序的艰难交锋:subprocess 调用exe踩坑实录
windows·python·ai编程
gameatp1 天前
从 Windows 到 Linux 服务器的全自动部署教程(免密登录 + 压缩 + 上传 + 启动)
linux·服务器·windows
穷人小水滴1 天前
在 windows 运行 flatpak 应用 (WSL)
linux·windows·ubuntu