參考:
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版本,參考以上三篇博客,因為環(huán)境原因一直出現(xiàn)各種問題,直到。。。發(fā)現(xiàn)了Msys2構(gòu)建平臺
** 想省事的同學可以直接下載編譯好的版本 (32bit) **:https://download.csdn.net/download/wml00876/88498301
-
MSYS2 官網(wǎng)
下載與安裝參考:
https://blog.csdn.net/qq_41898196/article/details/130102966
https://blog.csdn.net/B11050729/article/details/131719012
進入Mingw終端:
配置好環(huán)境后,打開目標終端,通過pacman指令安裝Podofo的依賴庫,部分指令如下:
# 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 官網(wǎng)GitHub
由于 pacman倉庫中維護的開源庫都是比較新的版本,openssl為3.x版本,所以podofo選擇較新版本0.10.x
0.10.x以后才可支持openssl 3.0
運行事例時發(fā)現(xiàn),podofo并不能支持pacman倉庫中的openssl版本3.1.x,雖然可以編譯構(gòu)建,但在程序中調(diào)用pdf庫時,會報錯:
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目錄中打開終端,執(zhí)行命令:
$ mingw32-make.exe
$ mingw32-make.exe install
成功后,openssl安裝在以下目錄:
-
編譯libjpeg
pacman 倉庫中有 mingw-w64-i686-libjpeg-turbo 3.0.1-1這個包,使用這個版本的jpeg庫make時會報錯:
: error: cannot convert 'PoDoFo::PdfIndirectObjectList' to 'HANDLE' {aka
'void*'}
500 | && (indirectobj = GetObject(*m_objects, ref)) != nullptr)
| ^~~~~~~~~~
| |
| PoDoFo::PdfIndirectObjectList
由于時間關(guān)系沒有研究 mingw-w64-i686-libjpeg-turbo 3.0.1-1 與 jpep官網(wǎng)上的版本有何區(qū)別,所以直接在官網(wǎng)下載了 jpegsr9e 版本,進行編譯:
Msys2終端進入解壓目錄,執(zhí)行以下命令:
$ ./configure
$ mingw32-make.exe
$ mingw32-make.exe install
完成后,相關(guān)文件直接安裝到Msys2環(huán)境中,目錄如下:
-
下載PODOFO源碼:
下載源碼后,解壓到 Msys2環(huán)境中的home(其它目錄也可以,根據(jù)個人習慣)
-
打開Cmake-gui
如果依賴庫提前安裝后,Cmake會自動讀取到(openssl如果無法讀取到,手動配置一下)
如果加載項目失敗,考慮C:\msys64\mingw32\bin添加到系統(tǒng)環(huán)境變量中
可能第一次加載需要選擇編譯器
-
執(zhí)行: configure 、Generate
遇到問題,查看配置項中的紅色部分文章來源:http://www.zghlxwxcb.cn/news/detail-742499.html
-
終端進入build目錄,執(zhí)行:
$ mingw32-make.exe
$ mingw32-make.exe install
構(gòu)建結(jié)束后,查看安裝目錄:
文章來源地址http://www.zghlxwxcb.cn/news/detail-742499.html
到了這里,關(guān)于windows + Mingw32-make 編譯 PoDoFo庫,openssl, libjpeg, Msys2工具的使用的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!