I solved this on Ubuntu by installing the libpango1.0-dev and libcairo-dev packages. I had also earlier installed the xorg-dev package, but I don't know if it is actually needed here.