How to Install Cairo 1.8.10 – Complete Guide


The package libcairo2-dev is the latest version of the Cairo graphics library (1.10.2). Is there any way I can install version 1.8.10?

I'm running 11.10, but would be interested in a general solution if possible.

Best Answer

If you want to test out an old version of Cairo, you can build it in a temporary prefix in your home directory.

First of all, make sure you've got Cairo's build dependencies installed. You can do this with the following command:

sudo apt-get build-dep cairo

Now download and unpack the old version of Cairo:

tar xzf cairo-1.8.10.tar.gz
cd cairo-1.8.10

Now you want to build Cairo into a temporary prefix. I've used ~/prefix for this on a few occasions, but you can use any directory.

./configure --prefix=$HOME/prefix
make install

Now you need to make your own software use this version of Cairo. If the software uses pkg-config to locate its dependencies, it should only be necessary to set the following environment variable:

export PKG_CONFIG_PATH=$HOME/prefix/lib/pkgconfig

If it isn't using pkg-config, you might need to adjust CFLAGS to include -I$HOME/prefix/include and LDFLAGS to include -L$HOME/prefix/lib.

Finally, to run your program using the custom version of Cairo you will need to configure the dynamic linker so it looks for shared libraries in your temporary prefix:

export LD_LIBRARY_PATH=$HOME/prefix/lib

Once that is set, you can verify that your program is linking against your copy of Cairo using ldd. If that looks okay, you're all done.

Cleaning Up

Once you're done with this temporary install, cleaning up is pretty easy. Just reset the environment variables and remove the temporary install prefix:

rm -rf $HOME/prefix

You may need to reconfigure/rebuild your program after doing this to make it use the system Cairo again.

Related Question