Build Poppler with non-default dependency installations
I need to build libvips with Poppler support for AWS Lambda and I want Poppler to use custom installations of libraries such as libtiff
, libpng
, fontconfig
, etc.
How can I configure the Poppler build to use my custom installed library versions from /opt
instead of the pre-installed one from \usr
?
I use the Docker image lambci/lambda:build-go1.x
to build Poppler and the needed libraries from source. Libraries such as libtiff
, libpng
, and fontconfig
are pre-installed on AWS Lambda, but their versions are outdated and have known security issues. I want to add the latest version to the layer and use that version instead of the pre-installed one. I'm installing to /opt
, i. e. using ./configure --prefix=/opt
or cmake .. -DCMAKE_INSTALL_PREFIX=/opt
, as layers are extracted to /opt
at runtime.
When building Poppler, Poppler is picking up the old versions from /usr/lib64
instead of the newer ones from /opt/lib
.
Poppler build output:
-- Found Freetype: /usr/lib64/libfreetype.so (found version "2.3.11")
-- Checking for module 'fontconfig'
-- Found fontconfig, version 2.13.1
-- Found Fontconfig: /usr/lib64/libfontconfig.so <== should be /opt/lib/libfontconfig.so
-- Found JPEG: /usr/lib64/libjpeg.so (found version "62")
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.8")
-- Found PNG: /usr/lib64/libpng.so (found version "1.2.49") <== should be /opt/lib/libpng.so, "1.6.37"
-- Found TIFF: /usr/lib64/libtiff.so (found version "4.0.3")
Relevant parts of my Dockerfile:
ENV BUILD_DIR="/tmp/build"
ENV INSTALL_DIR="/opt"
ENV PKG_CONFIG_PATH="${INSTALL_DIR}/lib64/pkgconfig:${INSTALL_DIR}/lib/pkgconfig" \
PKG_CONFIG="/usr/bin/pkg-config" \
PATH="${INSTALL_DIR}/bin:${PATH}"
ENV LD_LIBRARY_PATH="${INSTALL_DIR}/lib64:${INSTALL_DIR}/lib"
ENV LIBPNG_VERSION=1.6.37
ENV LIBPNG_BUILD_DIR=${BUILD_DIR}/libpng
RUN set -Eeuxo pipefail \
&& mkdir -p ${LIBPNG_BUILD_DIR} \
&& curl -L https://downloads.sourceforge.net/libpng/libpng-${LIBPNG_VERSION}.tar.xz \
| tar xJC ${LIBPNG_BUILD_DIR} --strip-components=1
WORKDIR ${LIBPNG_BUILD_DIR}/
RUN set -Eeuxo pipefail \
&& ./configure \
--prefix=${INSTALL_DIR} \
--disable-static \
&& make V=0 \
&& make install
ENV POPPLER_VERSION=0.89.0
ENV POPPLER_BUILD_DIR=${BUILD_DIR}/poppler
RUN set -Eeuxo pipefail \
&& mkdir -p ${POPPLER_BUILD_DIR}/build \
&& curl -L https://poppler.freedesktop.org/poppler-${POPPLER_VERSION}.tar.xz \
| tar xJC ${POPPLER_BUILD_DIR} --strip-components=1
WORKDIR ${POPPLER_BUILD_DIR}/build/
RUN set -Eeuxo pipefail \
&& LDFLAGS="-L${INSTALL_DIR}/lib64 -L${INSTALL_DIR}/lib" \
cmake .. \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} \
-DENABLE_UNSTABLE_API_ABI_HEADERS=ON \
-DENABLE_GLIB=ON \
-DENABLE_CPP=OFF \
-DENABLE_QT5=OFF \
-DENABLE_SPLASH=OFF \
-DPNG_INCLUDE_DIR=${INSTALL_DIR}/include \
-DPNG_LIBRARIES=${INSTALL_DIR}/lib64 \
&& make V=0 \
&& make install
My complete Dockerfile can be seen here.