Bug 145791 - Build fails with "--with-system-poppler"
Summary: Build fails with "--with-system-poppler"
Status: RESOLVED MOVED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: LibreOffice (show other bugs)
Version:
(earliest affected)
7.3.0.0 alpha0+
Hardware: All Linux (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-11-20 13:29 UTC by Kevin Suo
Modified: 2021-11-23 09:58 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kevin Suo 2021-11-20 13:29:05 UTC
Steps to Reproduce:

1. On a system without poppler-devel and without poppler-cpp, when I do 

$./autogen.sh

it gives:

checking for POPPLER... no
configure: error: Package requirements (poppler >= 0.12.0 ) were not met:

Package 'poppler', required by 'virtual:world', not found

This is good, and is expected.

2. Now, if I install poppler-devel:

$ sudo dnf install poppler-devel

and then do:

./autogen.sh

now the autogen will pass, code is ready to compile.

3. However, if now you take a look at the config_host/config_poppler.h file as generated by the autogen.sh script, you have the following:

#define HAVE_POPPLER_VERSION_H 0

which seems to indicate that you have an older poppler version installed which does not provided a poppler-version.h header. This #define was set by the configure.ac in line 11983:

if test "$ENABLE_PDFIMPORT" = "TRUE" -a "$ENABLE_POPPLER" = "TRUE"; then
    dnl ===================================================================
    dnl Check for system poppler
    dnl ===================================================================
    AC_MSG_CHECKING([which PDF import poppler to use])
    if test "$with_system_poppler" = "yes"; then
        AC_MSG_RESULT([external])
        SYSTEM_POPPLER=TRUE
        PKG_CHECK_MODULES( POPPLER, poppler >= 0.12.0 )
        AC_LANG_PUSH([C++])
        save_CXXFLAGS=$CXXFLAGS
        save_CPPFLAGS=$CPPFLAGS
        CXXFLAGS="$CXXFLAGS $POPPLER_CFLAGS"
        CPPFLAGS="$CPPFLAGS $POPPLER_CFLAGS"
        AC_CHECK_HEADER([cpp/poppler-version.h],
            [AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)],
            [])
        ...
    else
        AC_MSG_RESULT([internal])
        SYSTEM_POPPLER=
        BUILD_TYPE="$BUILD_TYPE POPPLER"
        AC_DEFINE([HAVE_POPPLER_VERSION_H], 1)
    fi
    AC_DEFINE([ENABLE_PDFIMPORT],1)
fi
...

The "test "$with_system_poppler"" block here is problematic. The cpp/poppler-version.h is a header file in the "poppler-cpp" package, not in the "poppler-devel" package (at least in my Fedora 34 system), so there will never be a cpp/poppler-version.h if there is no "poppler-cpp" package installed.

4. While it is fine that you can use an old poppler currently to build LibreOffice, however if the poppler version is not detected correctly, the build may fail, especially given that we the poppler internal has changed a lot overtime and we have so many poppler-version check codes in sdext/source/pdfimport.

For instance, based on step 3, since there is no configure error give, now if you do

make

then you will get the following (with a 21.01.0 version of system poppler):

In file included from /home/suokunlong/lo/source/core/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx:20:
/home/suokunlong/lo/source/core/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx:61:9: warning: 'POPPLER_VERSION' macro redefined [-Wmacro-redefined]
#define POPPLER_VERSION "0.12.3"
        ^
/usr/include/poppler/poppler-config.h:39:9: note: previous definition is here
#define POPPLER_VERSION "21.01.0"
        ^
In file included from /home/suokunlong/lo/source/core/sdext/source/pdfimport/xpdfwrapper/wrapper_gpl.cxx:20:
/home/suokunlong/lo/source/core/sdext/source/pdfimport/xpdfwrapper/pdfioutdev_gpl.hxx:136:13: error: unknown type name 'GBool'
    typedef GBool poppler_bool;

======

The solution either:

1. Add "poppler-cpp" as a dependency for --with-system-poppler. This approach is not perfect, as we only the poppler-cpp for version check, there is no actual poppler-cpp API code used in our libreoffice code base as far as I know. or

2. Force the poppler version with a --with-system-poppler poppler version to be the same as (or compatible with) the external_tarball version of poppler used, and remove those poppler version checks in sdext/source/pdfimport codes. (i.e. the same as how we handle 'orcus' and 'mdds'). Dealing this poppler version changes is proven to be a panic, as poppler's internal is changing in every release and we are not using the stable C++ API codes of poppler.
Comment 1 Michael Warner 2021-11-20 14:06:54 UTC
So, for reference, on my Linux Mint 20 system, the relevant package is named libpoppler-cpp-dev. 

I don't know much about GNU autotools, but should we really be checking for specific packages installed by the package manager? What if I downloaded poppler outside of the package system? It seems like configure should just check for the presence of the poppler-version.h file itself, not that a particular package is installed.
Comment 2 Xisco Faulí 2021-11-23 09:58:48 UTC
Hello Kevin,
Could you please send an email to the mailing list instead < https://wiki.documentfoundation.org/Development/Mailing_List >? For build issues, it's better than bugzilla.