Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Could you explain why you want to install the older version? Installing the older version system wide is probably not a possibility (some programs may depend on features of the newer release), but if you have a narrower requirement for the older version then a solution might be possible. –  James Henstridge Feb 29 '12 at 0:55
    
I personally know very little about Cairo, but I have written a program that links to a library that in turn uses Cairo to generate graphics. I did most of the original development on my Mac, for which Cairo installation was only available through something like Fink (which only has v1.8.10)... –  Daniel Standage Feb 29 '12 at 1:19
    
...The program also uses OpenMP, and one of the parallelized for loops includes calls to the Cairo library functions. The program works on Ubuntu when I run it on a single processor, and it works on Mac for any number of processors. But when I run it on Ubuntu with multiple processors, I get aborts, segfaults, glibcs, etc. –  Daniel Standage Feb 29 '12 at 1:20
    
I understand that downgrading to v1.8.10 isn't something you would want for a long term solution, and if you could isolate the installation it may even be better. I have already distributed the software and I simply want to have a temporary stop-gap until I can figure out what's really wrong with my program. –  Daniel Standage Feb 29 '12 at 1:21
    
For reference, the version numbers for Cairo go 1.8 -> 1.9 -> 1.10, so the version included with Ubuntu should be able to do everything the version you used on MacOS did. If you're only accessing Cairo through a third party library you aren't modifying, you shouldn't have to worry about accidentally using new features and breaking compatibility with your old development environment either. If you have run into a problem with the new version, could you explain what it is? –  James Henstridge Feb 29 '12 at 1:27

1 Answer 1

up vote 4 down vote accepted

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:

wget http://cairographics.org/releases/cairo-1.8.10.tar.gz
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
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:

unset LD_LIBRARY_PATH
unset PKG_CONFIG_PATH
rm -rf $HOME/prefix

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

share|improve this answer
    
Excellent and clear instructions, with a clean install and uninstall process. Thanks! –  Daniel Standage Feb 29 '12 at 16:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.