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

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

相关推荐
lpfasd12319 分钟前
WinSW在Win7上失败真相-实测与修复
windows·nginx
万山寒2 小时前
windows使用WinSW注册服务
windows
白搞电子4 小时前
ESP32-S31 项目如何制作 Windows 一键烧录包:完整镜像、esptool 与数据边界
windows·stm32·单片机
apple_692658854 小时前
Github开源免费 红果短剧 Windows 电脑桌面版:民间开发者做的第三方播放器,不用装模拟器了
windows
Vex2une5 小时前
Windows 系统还原发展史:从快照回滚到现代恢复生态
windows·系统还原·系统重置·卷影复制·系统保护·windows re·系统映像备份
Hello_Pyhx5 小时前
挖兔硬盘精灵 WatuDisk:从首次检测到日常检查的使用指南
运维·windows·硬盘·维护
seahahacsdn6 小时前
Windows系统添加VHD双系统
windows·vhd系统·vhd双系统
Hello_Pyhx11 小时前
iPhoneMirror:把 iPhone 接入 Windows,先分清投屏与反控
windows·ios·iphone
kakakahahahaha20 小时前
Win10开始菜单打不开排查:explorer、AppX注册、SFC、服务与用户配置修复
windows·电脑·笔记本电脑·内容运营·软件需求
ITHAOGE1521 小时前
下载 | Windows Server 2016最新纯净版ISO映像!(集成9月更新、标准版、数据中心版、14393.9514)
windows·科技·微软·电脑