cross-compile and pkgconfig

Enrico Weigelt weigelt at
Fri Sep 16 06:04:24 PDT 2005

* malet jean-luc <jean.luc.malet at> schrieb:

> in my mind : crosscompiling
> usually you do a
> ./configure --prefix=/usr
> make
> export DESTDIR=/path/to/embedded/FS
> make install
> this insure that all libtool and pkgconfig contain the right value (so 
> that you can boot on the target and compile new package fine) but the 
> issue is that querying the pkg-config about flags returns.... Host 
> directory.... which means that everything will fail awfully....

For clean crosscompiling you should use a sysroot'ed toolchain.
(crosstool is your friend for creating one).

You can adjust pkg-config's search pathes (PKG_CONFIG_LIBDIR,
PKG_CONFIG_PATH). And of you probly have to filter the output of 
pkg-config to add the sysroot prefix.
See attached script - you can use it as pkg-config frontend by 
setting the PKG_CONFIG variable (most packges should understand that)

> so I think that a good behaviour is to getenv(DESTDIR)
> and to change prefix to DESTDIR/prefix when outputing result....

No, that's a very bad way. $DESTDIR is *NOT* the place where we 
have to take everything from - it's the place where the freshly 
built package goes to. I personally use $SYSROOT instead.

 Enrico Weigelt    ==   metux IT service

  phone:     +49 36207 519931         www:
  fax:       +49 36207 519932         email:     contact at
  cellphone: +49 174 7066481
 -- DSL ab 0 Euro. -- statische IP -- UUCP -- Hosting -- Webshops --
-------------- next part --------------


if [ ! "$SYSROOT" ]; then
    echo "pkg-config-filter: missing \$SYSROOT environment variable"
    exit 2

#if [ ! "$PKG_CONFIG_LIBDIR" ]; then
#    export PKG_CONFIG_LIBDIR=$SYSROOT/usr/pkgconfig/


if $CMD $* |
    sed -e "s~\-L/*$SYSROOT/*~-L=/~g; s~\-I/*$SYSROOT/*~-I=/~g;" | # protect already given sysroot 
    sed -e "s~\-L/~-L=/~g; s~\-I/~-I=/~g;" | # add sysroot symbol to all absolute pathes
    sed -e "s~\-L\=~-L$SYSROOT~g; s~\-I\=~-I$SYSROOT~g;" # replace sysroot sign to sysroot path
    echo "OKAY" >&2;
    exit 0;
    echo "pkg-config failed!" >&2 
    exit 1

More information about the pkg-config mailing list