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

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

相关推荐
liulilittle6 小时前
.NET ExpandoObject 技术原理解析
开发语言·网络·windows·c#·.net·net·动态编程
cpsvps12 小时前
VR协作海外云:跨国企业沉浸式办公解决方案
windows·架构·vr·etw事件
义薄云天us14 小时前
019_工具集成与外部API调用
数据库·人工智能·windows·microsoft·claude code
RainbowSea14 小时前
安装win10出现“计算机意外的重新启动或遇到错误。Windows安装无法继续。若要安装Windows,请单击“确定”重新启动计算机,然后安装系统。”
windows·后端
bug攻城狮14 小时前
理解Grafana中`X-Scope-OrgID`的作用与配置
windows·grafana
扛枪的书生16 小时前
AD 提权-NTLM 中继攻击(强制认证)
windows·渗透·kali·提权·域渗透
hqxstudying17 小时前
Java行为型模式---观察者模式
java·开发语言·windows·观察者模式
Damon小智18 小时前
玩转ClaudeCode:ClaudeCode安装教程(Windows+Linux+MacOS)
windows·ai·mac·wsl·claude code·vibe code
CHANG_THE_WORLD20 小时前
libimagequant windows 编译
windows·libimagequant
xchenhao1 天前
基于 Flutter 的开源文本 TTS 朗读器(支持 Windows/macOS/Android)
android·windows·flutter·macos·openai·tts·朗读器