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

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

相关推荐
神秘剑客_CN4 小时前
使用vhd虚拟磁盘安装两个win10系统
windows
大道戏1 天前
如何本地部署DeepSeek
windows·ai·deepseek
skywalk81631 天前
在Windows下安装Ollama并体验DeepSeek r1大模型
人工智能·windows·ollama·deepseek
康世行1 天前
Windows环境下MaxKB大模型 Docker部署图文指南
windows·docker·容器
遗落凡尘的萤火-生信小白2 天前
单细胞-第四节 多样本数据分析,下游画图
windows·数据挖掘·数据分析
西农小陈2 天前
Python-基于PyQt5,json和playsound的通用闹钟
开发语言·windows·python·pycharm·pyqt
字节全栈_OYI2 天前
在Windows中 基于Oracle GoldenGate (OGG)进行MySQL->MySQL数据库同步配置(超详细)_ogg-15146
数据库·windows·oracle
Inori_3333 天前
Windows11暂停自动更新
windows·win11·暂停更新·windows update·windows更新
HilariousDog3 天前
clean code阅读笔记——如何命名?
windows·笔记