[cairo] cairo release 1.10.0, upgrade

Alexander Shulgin alex.shulgin at gmail.com
Thu Sep 9 22:48:19 PDT 2010


On Thu, Sep 9, 2010 at 19:57, Bill Spitzak <spitzak at gmail.com> wrote:
> Alexander Shulgin wrote:
>
>>> LD_LIBRARY_PATH=$HOME/lib
>>
>> No, that's shouldn't be necessary.  At least on Linux I have:
>>
>> ~/src/cairo-1.10.0/test$ ldd .libs/cairo-test-suite | grep /home
>>        libcairo.so.2 => /home/user/lib/libcairo.so.2 (0x00007fe52aa2e000)
>>        libpixman-1.so.0 => /home/user/lib/libpixman-1.so.0
>> (0x00007fe52a389000)
>>
>> And there's no LD_LIBRARY_PATH or something similar set in the environment
>
> I think you may be right. The problem may be that I had LD_LIBRARY_PATH set
> *before* I compiled and maybe this causes the linker to not store the full
> lib path name because it assumes it will still be set?

Now this is really strange.  I must admit my understanding of how ld
works on modern Linux systems is a bit outdated.

I've tried to compile a test file as simple as this:

#include <cairo.h>

int
main()
{
	cairo_surface_t* s = cairo_image_surface_create(100, 100, CAIRO_FORMAT_ARGB32);
	cairo_surface_destroy(s);
}

with the following command:

$ gcc cairo-test-ld.c `pkg-config --cflags --libs cairo`

which, thanks to PKG_CONFIG_PATH=/home/user/lib/pkgconfig, expands to

gcc cairo-test-ld.c -pthread -I/home/user/include/cairo
-I/home/user/include/pixman-1 -I/usr/include/glib-2.0
-I/usr/lib/glib-2.0/include -I/usr/include/freetype2
-I/usr/include/libpng12 -L/home/user/lib -lcairo

Now if I try to check which cairo it is linked to with this command:

$ ldd a.out | grep cairo
	libcairo.so.2 => /usr/lib/libcairo.so.2 (0x00007f1bf414b000)

it confuses me a lot.  For some reason during my past experience I
came to think that the exact path to the libraries is recorded in a
binary at the linking time, but obivously that's not true (now, or
never was).

So for a compiled program to use the locally installed cairo, it is
indeed required to set LD_LIBRARY_PATH at the time of execution:

$ LD_LIBRARY_PATH=~/lib ldd a.out | grep cairo
	libcairo.so.2 => /home/user/lib/libcairo.so.2 (0x00007fb808115000)

The fact that cairo's testsuite executable doesn't requires this
should be related to some libtool magic hidden behind the scenes, I
guess.

--
Alex


More information about the cairo mailing list