Install mupdf-plugin/backend for `zathura` document viewer

While the version that I have installed is zathura 0.3.5

This is the version of your zathura pdf viewer; the error message is for the development files for zathura plugins, which you can get by installing the package zathura-dev.


How do I install the plugin in Ubuntu (16.04)?

Here's a procedure to compile the plugin on Ubuntu 16.04 and 18.04.

First, you need to compile libmupdf-dev version 1.11.

Clone the repo of the project:

$ git clone --recursive git://git.ghostscript.com/mupdf.git

Enter its root directory:

$ cd mupdf

Checkout the branch tagged 1.11-rc1:

$ git checkout 1.11-rc1

Update the third party libraries:

$ git submodule update --init

Install some necessary dependencies:

$ sudo apt-get update
$ sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev mesa-common-dev pkg-config

Compile libmupdf-dev:

$ CFLAGS=-fPIC make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local
  ├──────────┘
  └ pass some flags to `$ gcc`, otherwise the compilation of `zathura-pdf-mupdf` will fail,
    with an error  message recommending you to recompile with those flags.

Install checkinstall to install the files as a deb package:

$ sudo apt-get install checkinstall

Use it to install the files under the package libmupdf-dev:

$ sudo checkinstall -y --pkgversion=1.11 --pkgname=libmupdf-dev

Now you can compile the zathura plugin. Get out of the mupdf/ directory and clone the repo of zathura-pdf-mupdf:

$ cd ..
$ git clone https://git.pwmt.org/pwmt/zathura-pdf-mupdf.git

Enter its root directory:

$ cd zathura-pdf-mupdf

Checkout the branch 0.3.1:

$ git checkout 0.3.1

Install some necessary dependencies:

$ sudo apt-get install libjbig2dec0-dev libjpeg-dev libopenjp2-7-dev libssl-dev zathura-dev

Finally, compile and install:

$ sudo make install

It seems that you can't easily go beyond the versions 1.11 and 0.3.1 for libmupdf-dev and zathura-pdf-mupdf, on Ubuntu 16.04. But on Ubuntu 18.04, you can go a little higher if you want:

┌───────┬──────────────┬───────────────────┐
│       │ libmupdf-dev │ zathura-pdf-mupdf │
├───────┼──────────────┼───────────────────┤
│ 16.04 │     1.11     │       0.3.1       │
├───────┼──────────────┼───────────────────┤
│ 18.04 │     1.13     │       0.3.2       │
└───────┴──────────────┴───────────────────┘

Which gives:

$ git clone --recursive git://git.ghostscript.com/mupdf.git
$ cd mupdf
$ git checkout 1.13.0-rc1
$ git submodule update --init
$ sudo apt-get update
$ sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev libxi-dev libxinerama-dev libxrandr-dev mesa-common-dev pkg-config
$ CFLAGS=-fPIC make HAVE_X11=no HAVE_GLUT=no prefix=/usr/local
$ sudo apt-get install checkinstall
$ sudo checkinstall -y --pkgversion=1.13 --pkgname=libmupdf-dev

$ cd ..
$ git clone https://git.pwmt.org/pwmt/zathura-pdf-mupdf.git
$ cd zathura-pdf-mupdf
$ git checkout 0.3.2
$ sudo apt-get install libjbig2dec0-dev libjpeg-dev libopenjp2-7-dev libssl-dev zathura-dev
$ sudo make install

If you want to remove the plugin, run:

$ sudo make uninstall

It will remove the /usr/lib/zathura/pdf.so from zathura-pdf-poppler, so reinstall the latter:

$ sudo apt-get install --reinstall zathura-pdf-poppler

Once the plugin is installed, you may need to make zathura the default program to open a pdf (and an epub); so run:

$ xdg-mime default zathura-pdf-mupdf.desktop application/pdf application/epub+zip

If the compilation of libmupdf-dev fails because of a missing file, try to find the package to which it belongs with $ apt-file search <file>, or read docs/building.html, header “Compiling on Linux” (if the file doesn't exist, temporarily switch to master $ git checkout master).

And maybe try to apply some debian patches before compiling:

$ git clone https://salsa.debian.org/koster/mupdf
$ ls mupdf/debian/patches
0001-mupdf_manpage.patch
0003-Sort-files-in-static-library-to-make-the-build-repro.patch
0003-use-debian-flavor-build-options.patch
0004-MuPDF-crossbuild-use-target-arch-pkg-config.patch
0005-MuPDF-crossbuild-use-host-cc-for-utils.patch
0006-Allow-disabling-objcopy.patch
0007-typographical-and-formatting-fixes-to-the-manual.patch
0008-PATCH-Fix-700043-Don-t-assume-a-font-is-t3-just-beca.patch
0009-PATCH-Bug-700442-Add-a-recursion-depth-check-to-prev.patch
0010-PATCH-Throw-when-page-number-is-out-of-range.patch
0011-Avoid-being-smart-about-keeping-only-a-single-refere.patch
0012-Fix-text-used-as-clip-mask-in-pdfwrite-device.patch
0013-Fix-typo-in-pdf-write-device.patch
series

Apply the ones you consider the most useful, by running this command while in the directory of the targeted file:

$ patch -b </path/to/patch

The -b option passed to $ patch creates a backup of a file before patching it. The backup file bears the extension .orig.

If you want to reverse the effect of a patch, use the -R option.

$ patch -R </path/to/patch
        ^^

And use --dry-run to simulate a patching.


The plugin is still not included in Debian repos and so I decided to package it myself.

I've uploaded zathura-pdf-mupdf package to Launchpad PPA ppa:spvkgn/zathura-mupdf, it contains packages for 16.04, 16.10, 17.04 and 17.10 Ubuntu series. The plugin compiled against library from latest MuPDF 1.11 version.

Please feel free to let me know if any issues with this package occurs.


A dirty and hacky way is to use the Arch binary.

Download and extract the binary /usr/lib/zathura/pdf.so from the package and copy it to e.g. /usr/lib/zathura/pdf.so on your Ubuntu machine. Better rename your existing pdf.so (poppler) to pdf.bu so it won't conflict.

The plugin is recognized:

$ zathura --version
zathura 0.3.5
(plugin) djvu (0.2.5) (/usr/lib/zathura/djvu.so)
(plugin) pdf-mupdf (0.3.0) (/usr/lib/zathura/pdf.so)
(plugin) ps (0.2.3) (/usr/lib/zathura/ps.so)
(plugin) cb (0.1.5) (/usr/lib/zathura/cb.so)

Till now I haven't seem much stability issues. Zathura is much faster then before, especially in rendering (huge images) and searching.

Be aware, in general it is not recommended to install software this way. It is a binary from a different distribution, it will not be updated nor patched automatically. Use it at your own risk.

Advantage is that the zathura-pdf-mupdf-0.3.0 plugin also supports the epub format.

Hopefully the plugin will be included in the Ubuntu repositories in the near future.