gdal icon indicating copy to clipboard operation
gdal copied to clipboard

Fails to build against Podofo 0.10.3 (on MinGW)

Open MehdiChinoune opened this issue 1 year ago • 6 comments

What is the bug?

Fails to build against podofo 0.10.3 Most probably bacause of https://github.com/OSGeo/gdal/commit/7b526b12e1ecb581c8ea3dff3e95a3ebc32eacec In https://github.com/OSGeo/gdal/blob/master/frmts/pdf/pdfsdk_headers.h

#ifdef GetObject
#undef GetObject
#endif

Should be put right before #include "podofo.h" No other header could be included between them.

with gcc 14.1.0

  [538/1307] Building CXX object frmts/pdf/CMakeFiles/gdal_PDF.dir/pdfdataset.cpp.obj
  FAILED: frmts/pdf/CMakeFiles/gdal_PDF.dir/pdfdataset.cpp.obj 
  C:\msys64\ucrt64\bin\g++.exe -DDONT_DEPRECATE_SPRINTF -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_PODOFO -DHAVE_PODOFO_0_10_OR_LATER -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DUSE_IMPORT_EXPORT -IC:/_/B/src/gdal-3.9.0/apps -IC:/_/B/src/gdal-3.9.0/alg -IC:/_/B/src/gdal-3.9.0/gcore -IC:/_/B/src/build-UCRT64-static/gcore -IC:/_/B/src/gdal-3.9.0/port -IC:/_/B/src/build-UCRT64-static/port -IC:/_/B/src/gdal-3.9.0/ogr -IC:/_/B/src/gdal-3.9.0/ogr/ogrsf_frmts -IC:/_/B/src/gdal-3.9.0/frmts -IC:/_/B/src/gdal-3.9.0/frmts/vrt -IC:/_/B/src/gdal-3.9.0/frmts/mem -IC:/_/B/src/gdal-3.9.0/ogr/ogrsf_frmts/mem -IC:/msys64/ucrt64/include/podofo -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -fvisibility=hidden -O3 -DNDEBUG -Wall -Wextra -Winit-self -Wunused-parameter -Wmissing-declarations -Wlogical-op -Wshadow -Wmissing-include-dirs -Wformat -Werror=format-security -Wno-format-nonliteral -Werror=vla -Wno-clobbered -Wdate-time -Wnull-dereference -Wextra-semi -
  In file included from C:/msys64/ucrt64/include/winnt.h:9,
                   from C:/msys64/ucrt64/include/minwindef.h:163,
                   from C:/msys64/ucrt64/include/windef.h:9,
                   from C:/msys64/ucrt64/include/windows.h:69,
                   from C:/_/B/src/gdal-3.9.0/port/cpl_spawn.h:45,
                   from C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp:39:
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp: In member function 'GDALPDFObject* PDFDataset::GetCatalog()':
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp:2511:41: error: 'class PoDoFo::PdfIndirectObjectList' has no member named 'GetObjectA'; did you mean 'GetObject'?
   2511 |             m_poDocPodofo->GetObjects().GetObject(
        |                                         ^~~~~~~~~
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp: In static member function 'static PDFDataset* PDFDataset::Open(GDALOpenInfo*)':
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp:4935:56: error: 'class PoDoFo::PdfPage' has no member named 'GetObjectA'; did you mean 'GetObject'?
   4935 |         const PoDoFo::PdfObject *pObj = &poPagePodofo->GetObject();
        |                                                        ^~~~~~~~~
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp:5523:27: error: 'const class PoDoFo::PdfInfo' has no member named 'GetObjectA'; did you mean 'GetObject'?
   5523 |                 &(poInfo->GetObject()),
        |                           ^~~~~~~~~

with clang 18.1.4

  [537/1307] Building CXX object frmts/pdf/CMakeFiles/gdal_PDF.dir/pdfdataset.cpp.obj
  FAILED: frmts/pdf/CMakeFiles/gdal_PDF.dir/pdfdataset.cpp.obj 
  C:\msys64\clang64\bin\clang++.exe -DDONT_DEPRECATE_SPRINTF -DGDAL_COMPILATION -DHAVE_AVX_AT_COMPILE_TIME -DHAVE_PODOFO -DHAVE_PODOFO_0_10_OR_LATER -DHAVE_SSE_AT_COMPILE_TIME -DHAVE_SSSE3_AT_COMPILE_TIME -DUSE_IMPORT_EXPORT -IC:/_/B/src/gdal-3.9.0/apps -IC:/_/B/src/gdal-3.9.0/alg -IC:/_/B/src/gdal-3.9.0/gcore -IC:/_/B/src/build-CLANG64-static/gcore -IC:/_/B/src/gdal-3.9.0/port -IC:/_/B/src/build-CLANG64-static/port -IC:/_/B/src/gdal-3.9.0/ogr -IC:/_/B/src/gdal-3.9.0/ogr/ogrsf_frmts -IC:/_/B/src/gdal-3.9.0/frmts -IC:/_/B/src/gdal-3.9.0/frmts/vrt -IC:/_/B/src/gdal-3.9.0/frmts/mem -IC:/_/B/src/gdal-3.9.0/ogr/ogrsf_frmts/mem -IC:/msys64/clang64/include/podofo -march=nocona -msahf -mtune=generic -O2 -pipe -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong -fno-finite-math-only -fvisibility=hidden -O3 -DNDEBUG -Wall -Wextra -Winit-self -Wunused-parameter -Wmissing-declarations -Wshorten-64-to-32 -Wshadow -Wshadow-field -Wmissing-include-dirs -Wformat -Werror=format-security -Wno-format-nonliteral -Werror=vla -Wdate-time -Wnull-dereference -Wextra-semi -Wcomma -Wfloat-conversion -Wdocumentation -Wno-documentation-deprecated-sync -Wunused-private-field -Wnon-virtual-dtor -Woverloaded-virtual -Wsuggest-override -fno-operator-names -Wzero-as-null-pointer-constant -MD -MT frmts/pdf/CMakeFiles/gdal_PDF.dir/pdfdataset.cpp.obj -MF frmts\pdf\CMakeFiles\gdal_PDF.dir\pdfdataset.cpp.obj.d -o frmts/pdf/CMakeFiles/gdal_PDF.dir/pdfdataset.cpp.obj -c C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp:2511:41: error: no member named 'GetObjectA' in 'PoDoFo::PdfIndirectObjectList'; did you mean 'GetObject'?
   2511 |             m_poDocPodofo->GetObjects().GetObject(
        |                                         ^~~~~~~~~
        |                                         GetObject
  C:/msys64/clang64/include/wingdi.h:3423:19: note: expanded from macro 'GetObject'
   3423 | #define GetObject __MINGW_NAME_AW(GetObject)
        |                   ^
  C:/msys64/clang64/include/_mingw_unicode.h:20:32: note: expanded from macro '__MINGW_NAME_AW'
     20 | # define __MINGW_NAME_AW(func) func##A
        |                                ^
  <scratch space>:94:1: note: expanded from here
     94 | GetObjectA
        | ^
  C:/msys64/clang64/include/podofo/main/PdfIndirectObjectList.h:157:16: note: 'GetObject' declared here
    157 |     PdfObject* GetObject(const PdfReference& ref) const;
        |                ^
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp:4935:56: error: no member named 'GetObjectA' in 'PoDoFo::PdfPage'
   4935 |         const PoDoFo::PdfObject *pObj = &poPagePodofo->GetObject();
        |                                          ~~~~~~~~~~~~  ^
  C:/msys64/clang64/include/wingdi.h:3423:19: note: expanded from macro 'GetObject'
   3423 | #define GetObject __MINGW_NAME_AW(GetObject)
        |                   ^
  C:/msys64/clang64/include/_mingw_unicode.h:20:32: note: expanded from macro '__MINGW_NAME_AW'
     20 | # define __MINGW_NAME_AW(func) func##A
        |                                ^
  <scratch space>:95:1: note: expanded from here
     95 | GetObjectA
        | ^
  C:/_/B/src/gdal-3.9.0/frmts/pdf/pdfdataset.cpp:5523:27: error: no member named 'GetObjectA' in 'PoDoFo::PdfInfo'
   5523 |                 &(poInfo->GetObject()),
        |                   ~~~~~~  ^
  C:/msys64/clang64/include/wingdi.h:3423:19: note: expanded from macro 'GetObject'
   3423 | #define GetObject __MINGW_NAME_AW(GetObject)
        |                   ^
  C:/msys64/clang64/include/_mingw_unicode.h:20:32: note: expanded from macro '__MINGW_NAME_AW'
  
     20 | # define __MINGW_NAME_AW(func) func##A
  
        |                                ^
  
  <scratch space>:96:1: note: expanded from here
  
     96 | GetObjectA
  
        | ^
  
  3 errors generated.

Steps to reproduce the issue

Install Podofo 0.10.3 and build gdal against it

Versions and provenance

Windows 2022 Server (GitHub) MSYS2 Platform in both UCRT64 and CLANG64 environments 3.9.0

Additional context

I am trying to build gdal against podofo instead of poppler, because It no longer builds with 24.05.0 (Even after backporting c++20 patches)

MehdiChinoune avatar May 21 '24 05:05 MehdiChinoune

The issue seems to be from podofo

MehdiChinoune avatar May 21 '24 06:05 MehdiChinoune

It's a gdal issue. in frmts/pdf/pdfdataset.cpp file gdal_pdf.h was included first before other headers which redefine GetObject (Which is used in pdfdataset.cpp).

MehdiChinoune avatar May 21 '24 10:05 MehdiChinoune

related discussion in podofo repository: https://github.com/podofo/podofo/issues/152. also see linked commits/PRs for more info

ognevny avatar May 21 '24 12:05 ognevny

I am trying to build gdal against podofo instead of poppler, because It no longer builds with 24.05.0 (Even after backporting c++20 patches)

That's a bad idea. I would recommend against using PoDoFo backend which has no rendering capabilities and will result in a driver without raster capabilities. What is the issue exactly with Poppler?

rouault avatar May 21 '24 19:05 rouault

That's a bad idea. I would recommend against using PoDoFo backend which has no rendering capabilities and will result in a driver without raster capabilities. What is the issue exactly with Poppler?

I got this type of error error: failed reading mapper, most probably a bug in gcc on mingw-w64 as It doesn't occur with gcc-14 on Arch and clang on mingw-w64.

MehdiChinoune avatar May 21 '24 20:05 MehdiChinoune

I got this type of error error: failed reading mapper, most probably a bug in gcc on mingw-w64 as It doesn't occur with gcc-14 on Arch and clang on mingw-w64.

It's a CMake issue https://gitlab.kitware.com/cmake/cmake/-/issues/25974

The issue is about podofo.

MehdiChinoune avatar May 22 '24 06:05 MehdiChinoune