cross compiling, pc files and `PKG_CONFIG_SYSROOT_DIR`

jcupitt at gmail.com jcupitt at gmail.com
Sun Jul 24 02:20:28 PDT 2011


Hi again Paul, sorry for my late answer, I only just stumbled upon
this thread again.

On 9 May 2011 14:48, Paul Menzel <paulepanter at users.sourceforge.net> wrote:
> Am Freitag, den 01.04.2011, 11:27 +0100 schrieb jcupitt at gmail.com:
>> On 1 April 2011 10:22, Paul Menzel <paulepanter at users.sourceforge.net> wrote:
>> > So it is `datadir=/usr/share` but for cross compiling it should be `${PKG_CONFIG_SYSROOT_DIR}/usr/share`.
>>
>> Perhaps you've tried this, but I usually use "--define-variable" when
>> cross-compiling. Before you start, set your PKG_CONFIG to be something
>> like:
>>
>>  $ export PKG_CONFIG="pkg-config --define-variable
>> datadir=${PKG_CONFIG_SYSROOT_DIR}/usr/share"
>>
>> and you'll override the setting in the .pc file (I've probably got the
>> quoting wrong).
>
> Thank you for the suggestion. I have not yet tried this. But as far as I
> can see the cross compile environment would need to make sure all
> pkg-config variables are adapted and that would be very cumbersome.
>
> Is there another solution which works out of the box? That would be
> highly appreciated.

I noticed that pygobject's .pc file has been fixed. On Ubuntu 11.04 I have:

$ more /usr/lib/pkgconfig/pygobject-2.0.pc
prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
datarootdir=${prefix}/share
datadir=${datarootdir}
libdir=${exec_prefix}/lib
..........

So you can now set prefix and datarootdir and hopefully that'll set
everything else correctly for you.

There's a separate issue that systems like win32 and OS X expect
packages to be relocatable at runtime, whereas Linux systems like to
have static paths for things like datadir. On OS X I generally make a
small wrapper script which sets environment variables to point to the
install directory. On win32, most packages which have been ported have
extra code in to discover their datadir at runtime.

I hope I've not misunderstood this thread too badly.

John


More information about the pkg-config mailing list