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

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

相关推荐
ZhengEnCi17 小时前
CMD 与 Python 完全区别指南-小白必看的编程入门解惑宝典
windows·python
华阙之梦19 小时前
【在 Windows 上运行 Apache Hadoop 或 Spark/GeoTrellis 涉及 HDFS 】
hadoop·windows·apache
电手20 小时前
微软宣布删除“另存为”选项,今后文件将默认保存到云盘
windows·microsoft·电脑·onedrive·windows11·windows10
AirDroid_cn1 天前
Win11 远程桌面:连接公司电脑时,提示 “证书错误” 如何解决?
windows·网络协议·https·ssl·电脑技巧
blackorbird1 天前
使用 Overpass Turbo 查找监控摄像头
运维·服务器·数据库·windows
zhuyasen1 天前
踩坑实录:Go 1.25.x 编译的 exe 在 Windows 提示“此应用无法运行”
windows·golang
千歌叹尽执夏1 天前
ubuntu24.04lts和Windows11家庭版远程桌面连接若干问题(解决)
windows·远程连接·xrdp·ubuntu24.04lts
sukalot2 天前
Windows显示驱动开发-支持显示输出和 ACPI 事件
windows
爱隐身的官人2 天前
Windows安全狗安装教程
windows·安全·安全设备
wulitoud2 天前
[好用工具] 一款mac/windows电脑历史剪切板工具,类似著名的Paste
windows·macos·sublime text