Saturday, March 28, 2009

Building Okular on Kubuntu Jaunty

The idea behind Okular is to have a universal document viewer, instead of one application for PDF, one for CHM, etc. Much like on Mac OS X, only better of course. ;)
Unfortunately, on the current release of Kubuntu, Jaunty Jackalope, Okular doesn’t display CHM files. There’s a bug report about this problem with status “fix released”. This isn’t actually as good as it sounds, since the fix is to remove the claim that the kdegraphics package (which contains Okular) supports the CHM format from the package description. Reminds me of what they say about how mathematicians answer questions; the answer is both correct and useless. ;)
So, what to do if you would like your Okular to actually display CHM files? How about building it from source? I know, this is tedious and basically defeats the whole point of having a distribution with “smart” package management. It would be slightly better to build a .deb from this custom binary and install it properly. I never bother doing this, though.
Anyway, here’s what I did. First make sure that you have your system set up to compile KDE stuff. It’s a good idea to pick a directory where you put all the code that you check out from KDE repositories (I chose ~/code/kde4) and a directory where you put the binaries (i.e. ~/apps/kde4). It’s recommended to set up some shell scripts to make the process more convenient. Check out this procedure on how to build KDevelop and/or the techbase article.
Install the development packages of the libraries that enable Okular to read all those file formats.
$ sudo apt-get install libchm-dev libepub-dev libdjvulibre-dev libpoppler-qt4-dev libspectre-dev libtiff-dev
You might assume that you can go ahead and just build Okular now, as described at That didn’t work for me. CMake failed with the following message:
CMake Error at ui/data/icons/CMakeLists.txt:1 (kde4_install_icons):
  Unknown CMake command "kde4_install_icons".

CMake Warning (dev) in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 2.6)

  should be added at the top of the file.  The version specified may be lower
  if you wish to support older CMake versions for this project.  For more
  information run "cmake --help-policy CMP0000".
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
The macro CMake talks about can be found in the file KDE4Macros.cmake, which is part of the package kdelibs5-dev. I had this package installed, but apparently CMake doesn’t look for modules where kdelibs5-dev puts it. The file resides in the directory /usr/share/kde4/apps/cmake/modules/. Sounds like a directory that CMake really should be looking for modules in, doesn’t it? To fix this, I added the line
prepend CMAKE_MODULE_PATH /usr/share/kde4/apps/cmake/modules
to ~/.kde/env/ If you ran CMake before doing this (like I did when I got the error message shown above), make sure to delete the file kdegraphics/CMakeCache.txt. I didn’t plan to build the entire kdegraphics package, but when I ran cmake in kdegraphics/okular I got the error about the missing kde4_install_icons macro again. Therefore I followed the steps given on the Okular download page. CMake then informed me, that I’m missing some optional dependencies, which I installed with:
sudo apt-get install libqimageblitz-dev libgphoto2-dev libsane-dev libxxf86vm-dev libexiv2-dev libqca2-dev
That only set me back about 32 MB. Bring on the bloat! I’m well prepared. My root partition is 50 GB large. :) After that running
in kdegraphics/build finally finished without complaining and make did what it’s supposed to. Unfortunately, the binary that fell out of make refused to open chm files, showing the same error message as before. I got fed up with it and stopped trying to get Okular working. I got back to it tonight, trying to figure out what went wrong. But after svn up and make install it worked. So, I don’t know what problem was, but at least it works now. :)

No comments:

Post a Comment