[gdal-dev] Build GDAL PDF Driver with PDFium

Parveen Sharma sharma1981 at outlook.com
Tue Jan 14 03:27:36 PST 2025


Hi

I was able to build the PDFium lib in release mode in Windows from https://github.com/rouault/pdfium_build_gdal_3_9. My requirement is to build the PDFium lib in DEBUG mode as well. For that I updated below args in args_release_win.gn with below argument


is_debug = true  # Enable debugging features.


With above change. the PDFium.lib is regenerated but when I try to link it with the Debug build of GDAL 3.9.3 then I get below link errors

2>pdfium.lib(fpdf_view.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_page.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_occontext.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_document.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_pagerendercontext.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_rendercontext.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_progressiverenderer.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_renderoptions.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(cpdf_annotlist.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj
2>pdfium.lib(renderdevicedriver_iface.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ogrpdflayer.obj

Is there a known way to fix the above errors by building PDFium.lib with required iterator_debug_level?

I also tried to enable below flag in args_release_win.gn

enable_iterator_debugging=true

BUT this leads to new vector allocator related errors

[95/1307] CXX obj/base/allocator/partition_allocator/src/partition_alloc/allocator_core/lightweight_quarantine.obj
FAILED: obj/base/allocator/partition_allocator/src/partition_alloc/allocator_core/lightweight_quarantine.obj
..\..\third_party\llvm-build\Release+Asserts\bin\clang-cl.exe /c ../../base/allocator/partition_allocator/src/partition_alloc/lightweight_quarantine.cc /Foobj/base/allocator/partition_allocator/src/partition_alloc/allocator_core/lightweight_quarantine.obj /nologo /showIncludes:user "-imsvc../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include" "-imsvc../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/ATLMFC/include" "-imsvc../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/VS/include" "-imsvc../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.22621.0/ucrt" "-imsvc../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.22621.0/um" "-imsvc../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.22621.0/shared" "-imsvc../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.22621.0/winrt" "-imsvc../../../../../../Program Files (x86)/Windows Kits/10/include/10.0.22621.0/cppwinrt" "-imsvc../../../../../../Program Files (x86)/Windows Kits/NETFXSDK/4.8/include/um" -DUSE_AURA=1 -D_HAS_NODISCARD -D_CRT_NONSTDC_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE "-DCR_CLANG_REVISION=\"llvmorg-18-init-17730-gf670112a-3\"" -D_HAS_EXCEPTIONS=0 -D__STD_C -D_CRT_RAND_S -D_CRT_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_DEPRECATE -D_ATL_NO_OPENGL -D_WINDOWS -DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS -DPSAPI_VERSION=2 -DWIN32 -D_SECURE_ATL -DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP -DWIN32_LEAN_AND_MEAN -DNOMINMAX -D_UNICODE -DUNICODE -DNTDDI_VERSION=NTDDI_WIN10_NI -D_WIN32_WINNT=0x0A00 -DWINVER=0x0A00 -D_DEBUG -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DIS_PARTITION_ALLOC_IMPL -I../.. -Igen -I../../base/allocator/partition_allocator/src -Igen/base/allocator/partition_allocator/src /W4 -Wimplicit-fallthrough -Wextra-semi -Wunreachable-code-aggressive -Wthread-safety -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi -Wloop-analysis -Wno-unneeded-internal-declaration -Wno-nonportable-include-path -Wenum-compare-conditional -Wno-ignored-pragma-optimize -Wno-deprecated-builtins -Wno-bitfield-constant-conversion -Wno-deprecated-this-capture -Wno-invalid-offsetof -Wno-vla-extension -Wno-thread-safety-reference-return -Wshadow /WX -fno-delete-null-pointer-checks -fno-ident -fcolor-diagnostics -fmerge-all-constants -fcrash-diagnostics-dir=../../tools/clang/crashreports -mllvm -instcombine-lower-dbg-declare=0 -mllvm -split-threshold-for-reg-with-hint=0 /clang:-ffp-contract=off -fcomplete-member-pointers /Gy /FS /bigobj /utf-8 /Zc:twoPhase -ffile-reproducible /Zc:sizedDealloc- /D__WRL_ENABLE_FUNCTION_STATICS__ -fmsc-version=1934 -m64 -msse3 /Brepro -Wno-builtin-macro-redefined -D__DATE__= -D__TIME__= -D__TIMESTAMP__= -ffile-compilation-dir=. -no-canonical-prefixes -ftrivial-auto-var-init=pattern /Z7 -gno-codeview-command-line -gcodeview-ghash -Xclang -fuse-ctor-homing /guard:cf,nochecks /MDd -Wheader-hygiene -Wstring-conversion -Wtautological-overlap-compare -Wexit-time-destructors /O2 /Ob2 /Oy- /Zc:inline /Gw /clang:-fno-math-errno -Wno-c++11-narrowing-const-reference -Wno-undefined-bool-conversion -Wno-tautological-undefined-compare /std:c++20 -Wno-trigraphs /TP /Fd"obj/base/allocator/partition_allocator/src/partition_alloc/allocator_core_cc.pdb"
In file included from ../../base/allocator/partition_allocator/src/partition_alloc/lightweight_quarantine.cc:5:
In file included from ../../base/allocator/partition_allocator/src\partition_alloc/lightweight_quarantine.h:42:
../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include\vector(611,38): error: no matching conversion for static_cast from '_Alty' (aka 'InternalAllocator<partition_alloc::internal::LightweightQuarantineBranch::QuarantineSlot>') to '_Rebind_alloc_t<_Alty, _Container_proxy>' (aka 'InternalAllocator<std::_Container_proxy>')
  611 |         _Mypair._Myval2._Alloc_proxy(_GET_PROXY_ALLOCATOR(_Alty, _Getal()));
      |                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../../Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.37.32822/include\xmemory(1492,42): note: expanded from macro '_GET_PROXY_ALLOCATOR'
 1492 | #define _GET_PROXY_ALLOCATOR(_Alty, _Al) static_cast<_Rebind_alloc_t<_Alty, _Container_proxy>>(_Al)


Any guidance?

________________________________
From: Even Rouault <even.rouault at spatialys.com>
Sent: Tuesday, January 14, 2025 8:32 AM
To: Parveen Sharma <sharma1981 at outlook.com>; David Klaus <dklaus at carlsonsw.com>
Cc: Michał Kowalczuk via gdal-dev <gdal-dev at lists.osgeo.org>
Subject: Re: [gdal-dev] Build GDAL PDF Driver with PDFium



Le 14/01/2025 à 01:23, Parveen Sharma a écrit :
Thanks Even

As i am building GDAL 3.9.3, so i will use the scripts in the https://github.com/rouault/pdfium_build_gdal_3_9 repository to build a patched version of PDFium.

Would you recommend using the "master" OR the "pdfium_6309_v1" branch of the above repository? I need to build GDAL with PDF Dynamic driver  in both Windows and Linux.

They're the same (except an edit in the readme file that doesn't matter as far as doing builds is concerned)


--
http://www.spatialys.com
My software is free, but my time generally not.
Butcher of all kinds of standards, open or closed formats. At the end, this is just about bytes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250114/d6280761/attachment-0001.htm>


More information about the gdal-dev mailing list