CAPS Universe documentation  1.0.4
All you need to know to be successful
PDF rasterizer

Rasterizing Portable Document Format

It wasn't such easy for me to get a working muPDF. They invent their own buildsystem and do not provide a pkg-config file and thus, it is hard to guess all the dependencies.

Installing a development muPDF variant from within my distribution was a nightmare. But it worked with the following packages:

  • libjbig2dec0-dev
  • libopenjp2-7-dev
  • libjpeg-turbo8-dev
  • libfreetype-dev
  • libharfbuzz-dev
  • libmupdf-dev

My libmupdf-dev package came with a broken pkg-config file and required a repaired one at a well known location. I added the mupdf.pc with the following content into /usr/lib/pkgconfig:

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: mupdf
Description: Library for rendering PDF documents
Requires.private: freetype2 jbig2dec libopenjp2 libjpeg harfbuzz
Version: 1.15.0
Libs: -L${libdir} -lmupdf
Libs.private: -lmupdf-third
Cflags: -I${includedir}

With this file libcapsraster's build system was happy, pkg-config as well and the linker was able to link all parts into one library.

But there is a different way available to get a working libmupdf:

Their git repository contains everything they need to build the library and use it at run-time: they include all dependencies into one single library. Building it is simple in this case. Just run a:

make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local

Useful additional options when compiling:

  • build=sanitize if the other parts of the CAPS universe are compiled with ASAN as well. ASAN is really helpful for development.
  • shared=yes to have a regular shared library (alternative is shared=no)
  • -j4 or similar if you have more than one CPU core

A debugging example:

make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local XCFLAGS=-fsanitize=address XLIBS=-lasan build=debug shared=yes
sudo make prefix=/usr/local build=debug shared=yes install

A release example:

make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local build=release shared=yes
sudo make prefix=/usr/local build=release shared=yes install
Note
Since this muPDF library contains all its dependencies, it is very large.
Their Makefile supports more options to use system libraries instead of their local one. Take a look into their Makethird file

For the case everything is compiled into muPDF add a simple pkg-config file to make libcapsraster's build system happy. Add a file called mupdf.pc with the following content into /usr/local/lib/pkgconfig:

prefix=/usr/local
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: mupdf
Description: Library for rendering PDF documents
Version: 1.15.0
Libs: -L${libdir} -lmupdf
Cflags: -I${includedir}
Note
If you want a different path than /usr/local replace it by your choice in all examples above.