Closed revathi-murali closed 4 years ago
Something about the way you've built pdfium, I guess. I know libvips itself builds fine on alpine.
C++ link problems are awful :( The two usual solutions are not to use -lc++
, or to link with g++
. You could check the .pc
file that pdfium build makes.
Sure I will check the .pc
file and update you.
I had issues (exactly this one - https://github.com/jcupitt/docker-builds/issues/2) linking pdfium with vips 8.7.4.
So, Im currently using separate microservices - one to do image processing by using vips and bimg without pdfium for all image formats and another one for all PDF operations without using vips by calling pdfium (by using pdfium binaries) and libjpeg header files using cgo.
I always was tried to build vips on debain based systems and ran into https://github.com/jcupitt/docker-builds/issues/2 this issue.
@jcupitt, Do you suggest me to use alpine based base image for linking pdfium with vips even for 8.7.4to avoid this issue (https://github.com/jcupitt/docker-builds/issues/2)?
@revathi-murali , If you've managed to make vips 8.7.4 to work with pdfium, could you please share that docker file?
Thanks
Build with pdfium needs fixing :( Let's leave this issue as a reminder.
Taking binaries from https://github.com/bblanchon/pdfium-binaries and then installing libicu-dev libc++-dev libc++abi-dev it seems to work. But I'm not sure how valid that approach is?
If it works, that's great, thank you for the update.
We need to sit down and fix this properly :(
If anyone needs pdfium working with binaries (without libvips) - refer this - https://stackoverflow.com/a/60254335/7438923
@jcupitt do you know if there is any progress on this?
I'm facing the same issue as OP. I need to build libvips with PDFium support for AWS Lambda (Amazon Linux 1).
I fetch the latest pre-built PDFium binary from https://github.com/bblanchon/pdfium-binaries and build libvips with the --with-pdfium-includes
and --with-pdfium-libraries
options pointing to the corresponding paths:
curl -L https://github.com/bblanchon/pdfium-binaries/releases/latest/download/pdfium-linux.tgz > pdfium-linux.tgz && \
mkdir -p /opt/pdfium-linux && \
tar -xf pdfium-linux.tgz -C /opt
./configure \
--prefix=/opt \
--disable-gtk-doc \
--without-magick \
--with-expat=/opt && \
--with-pdfium-includes=/opt/include \
--with-pdfium-libraries=/opt/lib
make && \
make install
Error message:
make[3]: Entering directory `/build/vips-8.9.2/libvips'
/bin/sh ../libtool --tag=CXX --mode=link g++ -g -O2 -no-undefined -version-info 54:2:12 -o libvips.la -rpath /opt/lib resample/libresample.la arithmetic/libarithmetic.la colour/libcolour.la conversion/libconversion.la convolution/libconvolution.la deprecated/libdeprecated.la foreign/libforeign.la freqfilt/libfreqfilt.la histogram/libhistogram.la draw/libdraw.la iofuncs/libiofuncs.la morphology/libmorphology.la mosaicing/libmosaicing.la create/libcreate.la -lz -lpng12 -ltiff -ljpeg -pthread -lgthread-2.0 -lglib-2.0 -Wl,--export-dynamic -pthread -lgmodule-2.0 -lgobject-2.0 -lglib-2.0 -L/opt/lib -lexpat -llcms2 -L/opt/lib -lpdfium -lc++ -licuuc -lm
libtool: link: g++ -fPIC -DPIC -shared -nostdlib /usr/lib/gcc/x86_64-amazon-linux/4.8.5/../../../../lib64/crti.o /usr/lib/gcc/x86_64-amazon-linux/4.8.5/crtbeginS.o -Wl,--whole-archive resample/.libs/libresample.a arithmetic/.libs/libarithmetic.a colour/.libs/libcolour.a conversion/.libs/libconversion.a convolution/.libs/libconvolution.a deprecated/.libs/libdeprecated.a foreign/.libs/libforeign.a freqfilt/.libs/libfreqfilt.a histogram/.libs/libhistogram.a draw/.libs/libdraw.a iofuncs/.libs/libiofuncs.a morphology/.libs/libmorphology.a mosaicing/.libs/libmosaicing.a create/.libs/libcreate.a -Wl,--no-whole-archive -Wl,-rpath -Wl,/usr/lib64 -Wl,-rpath -Wl,/usr/lib64 -lz -lpng12 -ltiff -ljpeg -lgthread-2.0 -lgmodule-2.0 -lgobject-2.0 -lglib-2.0 -L/opt/lib /usr/lib64/libexpat.so -llcms2 -lpdfium -lc++ -licuuc -L/usr/lib/gcc/x86_64-amazon-linux/4.8.5 -L/usr/lib/gcc/x86_64-amazon-linux/4.8.5/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib/gcc/x86_64-amazon-linux/4.8.5/../../.. -lstdc++ -lm -lc -lgcc_s /usr/lib/gcc/x86_64-amazon-linux/4.8.5/crtendS.o /usr/lib/gcc/x86_64-amazon-linux/4.8.5/../../../../lib64/crtn.o -g -O2 -pthread -Wl,--export-dynamic -pthread -pthread -Wl,-soname -Wl,libvips.so.42 -o .libs/libvips.so.42.12.2
/usr/bin/ld: cannot find -lc++
collect2: error: ld returned 1 exit status
I also tried to build from source (see PDFium repo), but the ./build/install-build-deps.sh
script does not support Amazon Linux 1:
ERROR: The only supported distros are
Ubuntu 14.04 LTS (trusty with EoL April 2022)
Ubuntu 16.04 LTS (xenial with EoL April 2024)
Ubuntu 18.04 LTS (bionic with EoL April 2028)
Ubuntu 20.04 LTS (focal with Eol April 2030)
Ubuntu 19.04 (disco)
Ubuntu 19.10 (eoan)
Debian 8 (jessie) or later
I appreciate any help!
Sorry, we've been getting ready for the 8.10 release. Perhaps in the 8.11 cycle.
@jcupitt you don't have to apologize for anything ;) I'll try to use Poppler in the meantime. I hope improved PDFium support can make it into 8.11.
Just to continue on from #1837, I am able to successfully build libvips 8.9.1 (haven't test 8.10+ yet) referencing the latest linux build from https://github.com/bblanchon/pdfium-binaries and have tested pdf to jpg renders via both CLI and Sharp with no issue. Fortunately the warning doesn't appear to be fatal. I am happy to provide a dockerfile or guidance for anyone struggling with the libc++ libicu linkage step.
I am happy to provide a dockerfile or guidance for anyone struggling with the libc++ libicu linkage step.
@Projkt-James I would gladly see the Dockerfile 👍
I am happy to provide a dockerfile or guidance for anyone struggling with the libc++ libicu linkage step.
@Projkt-James I would gladly see the Dockerfile 👍
https://github.com/libvips/libvips/issues/1400#issuecomment-587005438
Nice! Dockerfile copied here for reference:
FROM ubuntu:16.04
# Specify pdfium version
ARG PdfiumVersion=4026
# Install pkg-config, etc.
RUN apt-get -yqq update \
&& apt-get clean \
&& apt-get install -yqq apt-utils pkg-config tzdata \
&& dpkg-reconfigure -f noninteractive tzdata
# Create .pc file for pkg-config
RUN echo "\n" \
"prefix=/home\n" \
"Name: pdfium\n" \
"Description: pdfium\n" \
"Version: $PdfiumVersion\n" \
"Requires:\n" \
"Libs: -L/home/lib -lpdfium\n" \
"Cflags: -I/home/include\n" > /home/pdfium.pc
# Download and extract pdfium binary
RUN cd /home \
&& wget --quiet https://github.com/bblanchon/pdfium-binaries/releases/download/chromium%2F$PdfiumVersion/pdfium-linux.tgz \
&& tar -xf pdfium-linux.tgz \
&& rm pdfium-linux.tgz
# Setting up paths for pkg-config
ENV LD_LIBRARY_PATH=/home/lib
ENV PKG_CONFIG_PATH=/home/
## COPY YOUR APP TO /app/src/yourApp
# BUILD YOUR APP
WORKDIR /app/src/yourApp
# RUN your app which is linked to pdfium
ENTRYPOINT [“./yourApp"]
I've fixed build with pdfium -- it builds cleanly against the current binary from https://github.com/bblanchon/pdfium-binaries
There's a comment in pdfiumload.c with build notes:
/* How to build against PDFium:
*
* Download the prebuilt binary from:
*
* https://github.com/bblanchon/pdfium-binaries
*
* Untar to the libvips install prefix, for example:
*
* cd ~/vips
* tar xf ~/pdfium-linux.tgz
*
* Create a pdfium.pc like this (update the version number):
*
VIPSHOME=/home/john/vips
cat > $VIPSHOME/lib/pkgconfig/pdfium.pc << EOF
prefix=$VIPSHOME
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: pdfium
Description: pdfium
Version: 4290
Requires:
Libs: -L\${libdir} -lpdfium
Cflags: -I\${includedir}
EOF
*
*/
Then just ./configure
etc and it should build cleanly and work.
I'll try to add support for VipsSource as well.
OK, all done! I'll close. This will be in 8.11. Thanks for explaining how to fix the linking.
I decided to give it a try again. My setup differs slightly since I need to build for lambda (everything must end up in /opt
)
Unfortunately, libvips is no detecting my pdfium installation. I created pdfium.pc
in /opt/lib/pkgconfig
(which is in my PKG_CONFIG_PATH
) with the following content:
prefix=/opt
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
Name: pdfium
Description: pdfium
Version: 4313
Requires:
Libs: -L${libdir} -lpdfium
Cflags: -I${includedir}
and extracted the pre-built binaries into /opt
.
libvips' output includes the following lines:
checking for PDFIUM... libraries (none), headers -I/opt/include
PDF import with PDFium: no
I can't really see what is wrong with my setup.
I hope someone can help me here.
When I add the options --with-pdfium-includes=${INSTALL_DIR}/include
and --with-pdfium-libraries=${INSTALL_DIR}/lib
, livips recognizes pdfium.
However, the built later fails with:
make[3]: Entering directory `/tmp/build/libvips/libvips'
CXXLD libvips.la
/usr/bin/ld: cannot find -lc++
collect2: error: ld returned 1 exit status
make[3]: *** [libvips.la] Error 1
make[3]: Leaving directory `/tmp/build/libvips/libvips'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/tmp/build/libvips/libvips'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/tmp/build/libvips'
make: *** [all] Error 2
which it doesn't when built without pdfium support.
Shouldn't --with-pdfium-includes
and --with-pdfium-libraries
options normally be unnecessary since libvips will auto-detect those using pkgconfig?
Hi @asterikx, thanks for testing this.
libvips' output includes the following lines: checking for PDFIUM... libraries (none), headers -I/opt/include
That looks odd. I see:
checking for PDFIUM... yes
configure: WARNING: PDFium found, disabling poppler
I wonder if you don't have git master libvips, or if you've not run autogen.sh
since updating it?
For reference, my config.log
looks like this:
configure:20958: checking for PDFIUM
configure:20965: $PKG_CONFIG --exists --print-errors "pdfium >= 4200"
configure:20968: $? = 0
configure:20982: $PKG_CONFIG --exists --print-errors "pdfium >= 4200"
configure:20985: $? = 0
configure:21027: result: yes
configure:21034: WARNING: PDFium found, disabling poppler
My pkg-config
shows:
john@yingna ~/GIT/libvips (master) $ pkg-config pdfium --libs
-L/home/john/vips/lib -lpdfium
john@yingna ~/GIT/libvips (master) $ pkg-config pdfium --cflags
-I/home/john/vips/include
Oh heh I just saw your dockerfile, sorry.
Yes, this fix is git master libvips only, and you will need to use autogen.sh
, not configure
.
@jcupitt thank you! It finally works 🙂
Sorry for noise on this ticket, but I've gotten this built locally and I'm not sure how to tell if it's actually using PDFium? I see this in config.log:
3035-configure:21056: checking for RSVG
3036-configure:21063: $PKG_CONFIG --exists --print-errors "librsvg-2.0 >= 2.40.3 cairo >= 1.2"
3037-configure:21066: $? = 0
3038-configure:21080: $PKG_CONFIG --exists --print-errors "librsvg-2.0 >= 2.40.3 cairo >= 1.2"
3039-configure:21083: $? = 0
3040-configure:21129: result: yes
but vips -l
still shows poppler?
VipsForeignLoadPdfFile (pdfload), load PDF with libpoppler (.pdf), priority=0, is_a, get_flags, get_flags_filename, header, load
VipsForeignLoadPdfBuffer (pdfload_buffer), load PDF with libpoppler, priority=0, is_a_buffer, get_flags, get_flags_filename, header, load```
Is there any way to tell if pdfium is actually being used by libvips? Should I remove poppler from the system so there's no chance it's used?
Hi @nator,
You should see:
$ vips -l | grep -i pdf
VipsForeignLoadPdf (pdfload_base), load PDF with PDFium, priority=0
...
If you have both pdfium and poppler installed, libvips will pick pdfium, so I would guess your pdfium install probably failed somehow. Did you make the .pc
file?
Oops I pasted the entirely wrong line from config.log :(
configure:20848: gcc -c -g -O2 -I/usr/local/include conftest.c >&5
configure:20848: $? = 0
configure:20882: gcc -o conftest -g -O2 -I/usr/local/include conftest.c -L/usr/local/lib -lpdfium -lc++ -licuuc >&5
configure:20882: $? = 0
configure:20912: result: libraries /usr/local/lib, headers -I/usr/local/include
configure:20930: WARNING: PDFium found, disabling poppler
Yes, I made the .pc file, but let me double check everything one last time now that I know to expect "load PDF with PDFium" in vips -l
. Thanks for answering!
The safest check is the summary at the end of configure. During configure you should see:
...
checking for HEIF_AVIF... no
checking for struct heif_decoding_options.convert_hdr_to_8bit... no
checking for PDFIUM... yes
configure: WARNING: PDFium found, disabling poppler
checking for RSVG... yes
checking for ZLIB... yes
...
Then in the summary at the end:
...
file import with matio: yes
PDF import with PDFium: yes
PDF import with poppler-glib: no
(requires poppler-glib 0.16.0 or later)
SVG import with librsvg-2.0: yes
...
I think I mixed up my docker scripts and I've been building 8.10.2 instead of master. :( Trying that...
There's 8.10.4 now and it includes a fixed PDFium build. I'd try that.
Hmm. I'm stumped:
root@28d2d1efdea9:/vips-8.10.4# grep PDF config.log
configure:20825: checking for PDFIUM
configure:20930: WARNING: PDFium found, disabling poppler
| #define HAVE_PDFIUM 1
PDF import with PDFium: yes
PDF import with poppler-glib: no
root@28d2d1efdea9:/# vips -v
vips-8.10.4-Mon Dec 14 09:20:17 UTC 2020
root@28d2d1efdea9:/# vips -l | grep -i pdf
VipsForeignLoadPdf (pdfload_base), load PDF with libpoppler, priority=0
VipsForeignLoadPdfFile (pdfload), load PDF with libpoppler (.pdf), priority=0, is_a, get_flags, get_flags_filename, header, load
VipsForeignLoadPdfBuffer (pdfload_buffer), load PDF with libpoppler, priority=0, is_a_buffer, get_flags, get_flags_filename, header, load
With 8.10.4 I did not use autogen.sh -- is that still required maybe? I'm building on Ubuntu 20.04 due to upstream requirements, if that helps debug this at all...
ah, built by hand and I see lots of build errors I was missing in docker:
In file included from ../../libvips/include/vips/vips.h:130,
from pdfiumload.c:62:
pdfiumload.c: In function ‘vips_foreign_load_pdf_close’:
pdfiumload.c:148:33: warning: passing argument 1 of ‘FPDF_ClosePage’ from incompatible pointer type [-Wincompatible-pointer-types]
148 | VIPS_FREEF( FPDF_ClosePage, pdf->page );
../../libvips/include/vips/memory.h:42:28: note: in definition of macro ‘VIPS_FREEF’
42 | (void) F( (S) ); \
| ^
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:905:57: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’
905 | FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page);
| ~~~~~~~~~~^~~~
In file included from ../../libvips/include/vips/vips.h:130,
from pdfiumload.c:62:
pdfiumload.c:149:37: warning: passing argument 1 of ‘FPDF_CloseDocument’ from incompatible pointer type [-Wincompatible-pointer-types]
149 | VIPS_FREEF( FPDF_CloseDocument, pdf->doc );
../../libvips/include/vips/memory.h:42:28: note: in definition of macro ‘VIPS_FREEF’
42 | (void) F( (S) ); \
| ^
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:913:65: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’
913 | FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document);
| ~~~~~~~~~~~~~~^~~~~~~~
In file included from ../../libvips/include/vips/vips.h:130,
from pdfiumload.c:62:
pdfiumload.c: In function ‘vips_foreign_load_pdf_get_page’:
pdfiumload.c:222:34: warning: passing argument 1 of ‘FPDF_ClosePage’ from incompatible pointer type [-Wincompatible-pointer-types]
222 | VIPS_FREEF( FPDF_ClosePage, pdf->page );
../../libvips/include/vips/memory.h:42:28: note: in definition of macro ‘VIPS_FREEF’
42 | (void) F( (S) ); \
| ^
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:905:57: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’
905 | FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page);
| ~~~~~~~~~~^~~~
pdfiumload.c:229:39: warning: passing argument 1 of ‘FPDF_LoadPage’ from incompatible pointer type [-Wincompatible-pointer-types]
229 | if( !(pdf->page = FPDF_LoadPage( pdf->doc, page_no )) ) {
| ~~~^~~~~
| |
| struct fpdf_document_t__ **
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:662:65: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’
662 | FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document,
| ~~~~~~~~~~~~~~^~~~~~~~
pdfiumload.c:229:19: warning: assignment to ‘struct fpdf_page_t__ **’ from incompatible pointer type ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} [-Wincompatible-pointer-types]
229 | if( !(pdf->page = FPDF_LoadPage( pdf->doc, page_no )) ) {
| ^
pdfiumload.c: In function ‘vips_foreign_load_pdf_set_image’:
pdfiumload.c:289:30: warning: passing argument 1 of ‘FPDF_GetMetaText’ from incompatible pointer type [-Wincompatible-pointer-types]
289 | len = FPDF_GetMetaText( pdf->doc, metadata->tag, text, 1024 );
| ~~~^~~~~
| |
| struct fpdf_document_t__ **
In file included from pdfiumload.c:71:
/usr/include/fpdf_doc.h:388:72: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’
388 | FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document,
| ~~~~~~~~~~~~~~^~~~~~~~
pdfiumload.c: In function ‘vips_foreign_load_pdf_header’:
pdfiumload.c:331:39: warning: passing argument 1 of ‘FPDF_GetPageCount’ from incompatible pointer type [-Wincompatible-pointer-types]
331 | pdf->n_pages = FPDF_GetPageCount( pdf->doc );
| ~~~^~~~~
| |
| struct fpdf_document_t__ **
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:650:63: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’
650 | FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document);
| ~~~~~~~~~~~~~~^~~~~~~~
In file included from ../../libvips/include/vips/vips.h:116,
from pdfiumload.c:62:
pdfiumload.c:366:26: warning: passing argument 1 of ‘FPDF_GetPageWidth’ from incompatible pointer type [-Wincompatible-pointer-types]
366 | FPDF_GetPageWidth( pdf->page ) * pdf->scale );
| ~~~^~~~~~
| |
| struct fpdf_page_t__ **
../../libvips/include/vips/util.h:71:40: note: in definition of macro ‘VIPS_RINT’
71 | #define VIPS_RINT( V ) __builtin_rint( V )
| ^
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:685:62: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’
685 | FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page);
| ~~~~~~~~~~^~~~
In file included from ../../libvips/include/vips/vips.h:116,
from pdfiumload.c:62:
pdfiumload.c:368:27: warning: passing argument 1 of ‘FPDF_GetPageHeight’ from incompatible pointer type [-Wincompatible-pointer-types]
368 | FPDF_GetPageHeight( pdf->page ) * pdf->scale );
| ~~~^~~~~~
| |
| struct fpdf_page_t__ **
../../libvips/include/vips/util.h:71:40: note: in definition of macro ‘VIPS_RINT’
71 | #define VIPS_RINT( V ) __builtin_rint( V )
| ^
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:707:63: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’
707 | FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page);
| ~~~~~~~~~~^~~~
pdfiumload.c: In function ‘vips_foreign_load_pdf_generate’:
pdfiumload.c:457:37: warning: passing argument 2 of ‘FPDF_RenderPageBitmap’ from incompatible pointer type [-Wincompatible-pointer-types]
457 | FPDF_RenderPageBitmap( bitmap, pdf->page,
| ~~~^~~~~~
| |
| struct fpdf_page_t__ **
In file included from pdfiumload.c:70:
/usr/include/fpdfview.h:860:64: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’
860 | FPDF_PAGE page,
| ~~~~~~~~~~^~~~
pdfiumload.c: In function ‘vips_foreign_load_pdf_file_header’:
pdfiumload.c:614:17: warning: assignment to ‘struct fpdf_document_t__ **’ from incompatible pointer type ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} -Wincompatible-pointer-types]
614 | if( !(pdf->doc = FPDF_LoadDocument( file->filename, NULL )) ) {
| ^
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../.. -I../../libvips/include -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -pthread -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libgsf-1 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/local/include/ImageMagick-7 -I/usr/include/libpng16 -I/usr/include/libexif -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -pthread -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/local/include -I/usr/include/OpenEXR -I/usr/include/openslide -I/usr/include/x86_64-linux-gnu -g -O2 -MT pdfload.lo -MD -MP -MF .deps/pdfload.Tpo -c pdfload.c -o pdfload.o >/dev/null 2>&1
pdfiumload.c: In function ‘vips_foreign_load_pdf_buffer_header’:
pdfiumload.c:690:17: warning: assignment to ‘struct fpdf_document_t__ **’ from incompatible pointer type ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} -Wincompatible-pointer-types]
690 | if( !(pdf->doc = FPDF_LoadMemDocument( buffer->buf->data,
| ^
I'm using the 4355 PDFium binary, perhaps that's too new...
Build with master and I'm sorted. Phew. Sorry for the endless thread :)
You're right, looking at the code you need git master libvips (8.11) for pdfium, I'd forgotten. Anyway, I'm glad it's working.
I made a demo Dockerfile that builds git master libvips against pdfium on 20.04, it might help someone:
https://github.com/jcupitt/docker-builds/blob/master/libvips-pdfium-ubuntu20.04/Dockerfile
Thanks John! That Dockerfile looks great :)
On Tue, Dec 15, 2020 at 11:06 AM John Cupitt notifications@github.com wrote:
You're right, looking at the code you need git master libvips (8.11) for pdfium, I'd forgotten. Anyway, I'm glad it's working.
I made a demo Dockerfile that builds git master libvips against pdfium on 20.04, it might help someone:
https://github.com/jcupitt/docker-builds/blob/master/libvips-pdfium-ubuntu20.04/Dockerfile
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/libvips/libvips/issues/1400#issuecomment-745430199, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACTZAXBFJLTXNMFEALMUETSU6JRPANCNFSM4INUWS3Q .
ah, built by hand and I see lots of build errors I was missing in docker:
In file included from ../../libvips/include/vips/vips.h:130, from pdfiumload.c:62: pdfiumload.c: In function ‘vips_foreign_load_pdf_close’: pdfiumload.c:148:33: warning: passing argument 1 of ‘FPDF_ClosePage’ from incompatible pointer type [-Wincompatible-pointer-types] 148 | VIPS_FREEF( FPDF_ClosePage, pdf->page ); ../../libvips/include/vips/memory.h:42:28: note: in definition of macro ‘VIPS_FREEF’ 42 | (void) F( (S) ); \ | ^ In file included from pdfiumload.c:70: /usr/include/fpdfview.h:905:57: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’ 905 | FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page); | ~~~~~~~~~~^~~~ In file included from ../../libvips/include/vips/vips.h:130, from pdfiumload.c:62: pdfiumload.c:149:37: warning: passing argument 1 of ‘FPDF_CloseDocument’ from incompatible pointer type [-Wincompatible-pointer-types] 149 | VIPS_FREEF( FPDF_CloseDocument, pdf->doc ); ../../libvips/include/vips/memory.h:42:28: note: in definition of macro ‘VIPS_FREEF’ 42 | (void) F( (S) ); \ | ^ In file included from pdfiumload.c:70: /usr/include/fpdfview.h:913:65: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’ 913 | FPDF_EXPORT void FPDF_CALLCONV FPDF_CloseDocument(FPDF_DOCUMENT document); | ~~~~~~~~~~~~~~^~~~~~~~ In file included from ../../libvips/include/vips/vips.h:130, from pdfiumload.c:62: pdfiumload.c: In function ‘vips_foreign_load_pdf_get_page’: pdfiumload.c:222:34: warning: passing argument 1 of ‘FPDF_ClosePage’ from incompatible pointer type [-Wincompatible-pointer-types] 222 | VIPS_FREEF( FPDF_ClosePage, pdf->page ); ../../libvips/include/vips/memory.h:42:28: note: in definition of macro ‘VIPS_FREEF’ 42 | (void) F( (S) ); \ | ^ In file included from pdfiumload.c:70: /usr/include/fpdfview.h:905:57: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’ 905 | FPDF_EXPORT void FPDF_CALLCONV FPDF_ClosePage(FPDF_PAGE page); | ~~~~~~~~~~^~~~ pdfiumload.c:229:39: warning: passing argument 1 of ‘FPDF_LoadPage’ from incompatible pointer type [-Wincompatible-pointer-types] 229 | if( !(pdf->page = FPDF_LoadPage( pdf->doc, page_no )) ) { | ~~~^~~~~ | | | struct fpdf_document_t__ ** In file included from pdfiumload.c:70: /usr/include/fpdfview.h:662:65: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’ 662 | FPDF_EXPORT FPDF_PAGE FPDF_CALLCONV FPDF_LoadPage(FPDF_DOCUMENT document, | ~~~~~~~~~~~~~~^~~~~~~~ pdfiumload.c:229:19: warning: assignment to ‘struct fpdf_page_t__ **’ from incompatible pointer type ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} [-Wincompatible-pointer-types] 229 | if( !(pdf->page = FPDF_LoadPage( pdf->doc, page_no )) ) { | ^ pdfiumload.c: In function ‘vips_foreign_load_pdf_set_image’: pdfiumload.c:289:30: warning: passing argument 1 of ‘FPDF_GetMetaText’ from incompatible pointer type [-Wincompatible-pointer-types] 289 | len = FPDF_GetMetaText( pdf->doc, metadata->tag, text, 1024 ); | ~~~^~~~~ | | | struct fpdf_document_t__ ** In file included from pdfiumload.c:71: /usr/include/fpdf_doc.h:388:72: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’ 388 | FPDF_EXPORT unsigned long FPDF_CALLCONV FPDF_GetMetaText(FPDF_DOCUMENT document, | ~~~~~~~~~~~~~~^~~~~~~~ pdfiumload.c: In function ‘vips_foreign_load_pdf_header’: pdfiumload.c:331:39: warning: passing argument 1 of ‘FPDF_GetPageCount’ from incompatible pointer type [-Wincompatible-pointer-types] 331 | pdf->n_pages = FPDF_GetPageCount( pdf->doc ); | ~~~^~~~~ | | | struct fpdf_document_t__ ** In file included from pdfiumload.c:70: /usr/include/fpdfview.h:650:63: note: expected ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} but argument is of type ‘struct fpdf_document_t__ **’ 650 | FPDF_EXPORT int FPDF_CALLCONV FPDF_GetPageCount(FPDF_DOCUMENT document); | ~~~~~~~~~~~~~~^~~~~~~~ In file included from ../../libvips/include/vips/vips.h:116, from pdfiumload.c:62: pdfiumload.c:366:26: warning: passing argument 1 of ‘FPDF_GetPageWidth’ from incompatible pointer type [-Wincompatible-pointer-types] 366 | FPDF_GetPageWidth( pdf->page ) * pdf->scale ); | ~~~^~~~~~ | | | struct fpdf_page_t__ ** ../../libvips/include/vips/util.h:71:40: note: in definition of macro ‘VIPS_RINT’ 71 | #define VIPS_RINT( V ) __builtin_rint( V ) | ^ In file included from pdfiumload.c:70: /usr/include/fpdfview.h:685:62: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’ 685 | FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageWidth(FPDF_PAGE page); | ~~~~~~~~~~^~~~ In file included from ../../libvips/include/vips/vips.h:116, from pdfiumload.c:62: pdfiumload.c:368:27: warning: passing argument 1 of ‘FPDF_GetPageHeight’ from incompatible pointer type [-Wincompatible-pointer-types] 368 | FPDF_GetPageHeight( pdf->page ) * pdf->scale ); | ~~~^~~~~~ | | | struct fpdf_page_t__ ** ../../libvips/include/vips/util.h:71:40: note: in definition of macro ‘VIPS_RINT’ 71 | #define VIPS_RINT( V ) __builtin_rint( V ) | ^ In file included from pdfiumload.c:70: /usr/include/fpdfview.h:707:63: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’ 707 | FPDF_EXPORT double FPDF_CALLCONV FPDF_GetPageHeight(FPDF_PAGE page); | ~~~~~~~~~~^~~~ pdfiumload.c: In function ‘vips_foreign_load_pdf_generate’: pdfiumload.c:457:37: warning: passing argument 2 of ‘FPDF_RenderPageBitmap’ from incompatible pointer type [-Wincompatible-pointer-types] 457 | FPDF_RenderPageBitmap( bitmap, pdf->page, | ~~~^~~~~~ | | | struct fpdf_page_t__ ** In file included from pdfiumload.c:70: /usr/include/fpdfview.h:860:64: note: expected ‘FPDF_PAGE’ {aka ‘struct fpdf_page_t__ *’} but argument is of type ‘struct fpdf_page_t__ **’ 860 | FPDF_PAGE page, | ~~~~~~~~~~^~~~ pdfiumload.c: In function ‘vips_foreign_load_pdf_file_header’: pdfiumload.c:614:17: warning: assignment to ‘struct fpdf_document_t__ **’ from incompatible pointer type ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} -Wincompatible-pointer-types] 614 | if( !(pdf->doc = FPDF_LoadDocument( file->filename, NULL )) ) { | ^ libtool: compile: gcc -DHAVE_CONFIG_H -I. -I../.. -I../../libvips/include -DG_DISABLE_ASSERT -DG_DISABLE_CHECKS -pthread -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pango-1.0 -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libgsf-1 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libxml2 -fopenmp -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 -I/usr/local/include/ImageMagick-7 -I/usr/include/libpng16 -I/usr/include/libexif -I/usr/lib/x86_64-linux-gnu/hdf5/serial/include -pthread -I/usr/include/librsvg-2.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/local/include -I/usr/include/OpenEXR -I/usr/include/openslide -I/usr/include/x86_64-linux-gnu -g -O2 -MT pdfload.lo -MD -MP -MF .deps/pdfload.Tpo -c pdfload.c -o pdfload.o >/dev/null 2>&1 pdfiumload.c: In function ‘vips_foreign_load_pdf_buffer_header’: pdfiumload.c:690:17: warning: assignment to ‘struct fpdf_document_t__ **’ from incompatible pointer type ‘FPDF_DOCUMENT’ {aka ‘struct fpdf_document_t__ *’} -Wincompatible-pointer-types] 690 | if( !(pdf->doc = FPDF_LoadMemDocument( buffer->buf->data, | ^
I'm using the 4355 PDFium binary, perhaps that's too new...
I was building with 8.9.1 and majority of the warnings are non fatal from what I can tell. A lot of the issues I was having inside docker for older libvips versions was linking of libcxx and libicu.
We are upgrading to libvips
8.8.1
and looks like there are some changes made in8.8.1
with pdfium linking and I get the following error when building vips:Command used to build libvips
Since alpine uses musl libc, I am not sure if glibc/libc++ works fine on musl. Any pointers on this?
Note: We are using the following patches already