jcupitt / docker-builds

Various sample dockerfiles
91 stars 31 forks source link

Pdfium Mac build #1

Open swftvsn opened 6 years ago

swftvsn commented 6 years ago

Hi,

trying to build pdfium on High Sierra (and eventually libvips with the support enabled) but the build ends to

ERROR at //pdfium.gni:73:1: Assertion failed.
assert(!pdf_is_complete_lib || !is_component_build,
^-----
pdf_is_complete_lib=true requires is_component_build=false

I changed the build command to gn gen "${BUILD_RES}" --args='pdf_bundle_freetype = true pdf_enable_v8 = false pdf_enable_xfa = false pdf_use_skia = false pdf_use_skia_paths = false is_component_build = true pdf_is_complete_lib = false pdf_is_standalone = false use_sysroot = false'

(changed pdf_is_complete_lib = false and added pdf_is_standalone = false)

as the google documentation described here: https://pdfium.googlesource.com/pdfium/

Is this OK or am I heading towards big problems?

I can produce tar.gz precisely the same as this: https://github.com/jcupitt/docker-builds/blob/master/pdfium/data/package/libpdfium-master-linux-x64.tar.gz, except the 3 .so files in the root of lib are .dylibs.

jcupitt commented 6 years ago

Hello!

Huh, strange. It's building master so perhaps things have shifted a bit since I last built it? I'd make the change they suggest and carry on.

I'll try again here too.

jcupitt commented 6 years ago

Looks like it's now writing llvm thin archives instead of regular fat gnu .a archives, so it'll break libvips linking with gcc later. Some other things have moved about too.

There must be an option to make a fat gnu archive. I'll keep looking.

jcupitt commented 6 years ago

Ah, found it, I think! It's working for me again now on linux anyway. Could you test on macOS?

It seems those .so files are gone too, which is probably a good thing.

swftvsn commented 6 years ago

Great! I'll test that tomorrow morning.

swftvsn commented 6 years ago

Morning!

I think the pdfium build is now ok! I can't get testable binaries yet though, as libvips build fails eventually.

I build libvips with this:

#!/bin/bash

. config.sh

export GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0:$VIPSHOME/lib/girepository-1.0
export PYTHONPATH=$VIPSHOME/lib/python2.7/site-packages:$PYTHONPATH

# Clone master
if [ ! -d "${BASE}/libvips" ]; then
  ${git} clone https://github.com/jcupitt/libvips.git
  cd libvips
else
  cd libvips
  ${git} pull
fi

# Build, make and install
export PDFIUM_INCLUDES="${BASE}/pdfium/include"
export PDFIUM_LIBS="${BASE}/pdfium/lib"
echo ${PDFIUM_INCLUDES}
CFLAGS="-g -Wall" CXXFLAGS="-g -Wall" ./autogen.sh --prefix=$HOME/vips --with-jpeg-includes=/usr/local/opt/jpeg-turbo/include --with-jpeg-libraries=/usr/local/opt/jpeg-turbo/lib --with-pdfium-includes=$PDFIUM_INCLUDES --with-pdfium-libraries=$PDFIUM_LIBS
make
make install

The echo ${PDFIUM_INCLUDES} prints out /Users/username/git/package-libvips-darwin/pdfium/include and --prefix=$HOME/vips is /Users/username/vips.

The files that are mentioned in the error message are present in /Users/username/git/package-libvips-darwin/pdfium/include but are NOT found at all in /Users/username/vips.

I'm getting a lot of these errors:

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libpdfium.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfpdfapi.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfxge.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfpdfdoc.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfxcrt.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfx_agg.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfxcodec.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfx_lpng.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfx_libopenjpeg.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfx_lcms2.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfx_freetype.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libjpeg.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libfdrm.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libpwl.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libbigint.a is not portable!

*** Warning: Linking the shared library libvips.la against the
*** static library /Users/username/vips/lib/pdfium-obj/libformfiller.a is not portable!
libtool: link: g++ -dynamiclib  -o .libs/libvips.42.dylib   -Wl,-force_load,resample/.libs/libresample.a -Wl,-force_load,arithmetic/.libs/libarithmetic.a -Wl,-force_load,colour/.libs/libcolour.a -Wl,-force_load,conversion/.libs/libconversion.a -Wl,-force_load,convolution/.libs/libconvolution.a -Wl,-force_load,deprecated/.libs/libdeprecated.a -Wl,-force_load,foreign/.libs/libforeign.a -Wl,-force_load,freqfilt/.libs/libfreqfilt.a -Wl,-force_load,histogram/.libs/libhistogram.a -Wl,-force_load,draw/.libs/libdraw.a -Wl,-force_load,iofuncs/.libs/libiofuncs.a -Wl,-force_load,morphology/.libs/libmorphology.a -Wl,-force_load,mosaicing/.libs/libmosaicing.a -Wl,-force_load,create/.libs/libcreate.a -Wl,-force_load,video/.libs/libvideo.a  -L/usr/local/Cellar/libpng/1.6.34/lib -lpng16 -lz -L/usr/local/Cellar/libtiff/4.0.9_2/lib -ltiff -L/usr/local/Cellar/jpeg/9c/lib -ljpeg -L/usr/local/Cellar/glib/2.56.1/lib -L/usr/local/opt/gettext/lib -lgmodule-2.0 -lexpat -L/usr/local/Cellar/pango/1.42.1/lib -L/usr/local/Cellar/fribidi/1.0.2/lib -L/usr/local/Cellar/fontconfig/2.12.6/lib -L/usr/local/opt/freetype/lib -lpangoft2-1.0 -lpango-1.0 -lfribidi -lfontconfig -lfreetype -L/usr/local/Cellar/libgsf/1.14.42/lib -lgsf-1 -lxml2 -L/usr/local/Cellar/fftw/3.3.7_1/lib -lfftw3 -L/usr/local/Cellar/orc/0.4.28/lib -lorc-0.4 -L/usr/local/Cellar/little-cms2/2.9/lib -llcms2 -lgif -L/usr/local/Cellar/librsvg/2.42.2_2/lib -L/usr/local/Cellar/gdk-pixbuf/2.36.12/lib -L/usr/local/Cellar/cairo/1.14.12/lib -lrsvg-2 -lgio-2.0 -lgdk_pixbuf-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lcairo /Users/username/vips/lib/pdfium-obj/libpdfium.a /Users/username/vips/lib/pdfium-obj/libfpdfapi.a /Users/username/vips/lib/pdfium-obj/libfxge.a /Users/username/vips/lib/pdfium-obj/libfpdfdoc.a /Users/username/vips/lib/pdfium-obj/libfxcrt.a /Users/username/vips/lib/pdfium-obj/libfx_agg.a /Users/username/vips/lib/pdfium-obj/libfxcodec.a /Users/username/vips/lib/pdfium-obj/libfx_lpng.a /Users/username/vips/lib/pdfium-obj/libfx_libopenjpeg.a /Users/username/vips/lib/pdfium-obj/libfx_lcms2.a /Users/username/vips/lib/pdfium-obj/libfx_freetype.a /Users/username/vips/lib/pdfium-obj/libjpeg.a /Users/username/vips/lib/pdfium-obj/libfdrm.a /Users/username/vips/lib/pdfium-obj/libpwl.a /Users/username/vips/lib/pdfium-obj/libbigint.a /Users/username/vips/lib/pdfium-obj/libformfiller.a -L/Users/username/git/package-libvips-darwin/pdfium/lib -lpthread -L/usr/local/Cellar/openexr/2.2.0/lib -L/usr/local/Cellar/ilmbase/2.2.0/lib -lIlmImf -lImath -lHalf -lIex -lIexMath -lIlmThread -L/usr/local/Cellar/openslide/3.4.1_4/lib -lopenslide -L/usr/local/Cellar/cfitsio/3.430/lib -lcfitsio -lcurl -L/usr/local/Cellar/webp/0.6.1/lib -lwebpmux -lwebp -L/usr/local/Cellar/libexif/0.6.21/lib -lexif -lm  -g -Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreFoundation   -install_name  /Users/username/vips/lib/libvips.42.dylib -compatibility_version 52 -current_version 52.0 -Wl,-single_module
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libpdfium.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfpdfapi.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfxge.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfpdfdoc.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfxcrt.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfx_agg.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfxcodec.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfx_lpng.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfx_libopenjpeg.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfx_lcms2.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfx_freetype.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libjpeg.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libfdrm.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libpwl.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libbigint.a'
clang: error: no such file or directory: '/Users/username/vips/lib/pdfium-obj/libformfiller.a'
make[2]: *** [libvips.la] Error 1
make[1]: *** [install-recursive] Error 1
make: *** [install-recursive] Error 1

Can you help me with this problem? Should I have the build bash file copy the files over there?

jcupitt commented 6 years ago

Huh strange, I'll try on my mac tonight. I guess you're using git master build-pdfium and libvips?

swftvsn commented 6 years ago

Yes, master of both. I'm actually working on this forked repo (Thanks @lovell) https://github.com/swftvsn/package-libvips-darwin and the associated Travis build is here: https://travis-ci.org/swftvsn/package-libvips-darwin to add pdfium support to sharp. (Or if pdfium is too hard / unstable for sharp then it's for my own use and anyone else needing this.)

swftvsn commented 6 years ago

Added you as a collaborator to that fork if you'd like to play around there.