pkg-config file cross-compile troubles

SK
Sebastian Kemper
Wed, Nov 6, 2019 6:50 PM

Hi all,

Somebody raised this issue on the OpenWrt telephony issue tracker. When
you cross-compile from inside a buildroot you always need to watch out
that no includes and whatnot from the host system are added. So the
pkg-config files need to be OK to use for cross-compile. For instance we
use a pkg-config script which calls the real pkg-config like this:

pkg-config.real --define-variable=prefix=${STAGING_PREFIX} --define-variable=exec_prefix=${STAGING_PREFIX} --define-variable=bindir=${STAGING_PREFIX}/bin $@

This way we update some variables commonly used in the .pc files.

The default libpjproject.pc file that gets installed contains this:

prefix=/usr
exec_prefix=${prefix}
libdir=/usr/lib
includedir=/usr/include

Name: libpjproject
Description: Multimedia communication library
URL: http://www.pjsip.org
Version: 2.9
Libs: -L${libdir} -lpjsua2 -lpjsua -lpjsip-ua -lpjsip-simple -lpjsip -lpjmedia-codec -lpjmedia -lpjmedia-videodev -lpjmedia-audiodev -lpjmedia -lpjnath -lpjlib-util  -lsrtp2 -lpj -lssl -lcrypto -luuid -lm -lrt -lpthread
Cflags: -I${includedir}  -I/usr/include -DPJ_AUTOCONF=1  -DPJ_IS_BIG_ENDIAN=1 -DPJ_IS_LITTLE_ENDIAN=0 -fPIC -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/include

So it contains a hardcoded libdir and includedir and also adds a
hardcoded -I/usr/include into the CFLAGS.

The attached patch fixes all that for us. I'm wondering if this can be
included upstream? If not that's fine, happy to carry the patch locally.

Kind regards,
Seb

Hi all, Somebody raised this issue on the OpenWrt telephony issue tracker. When you cross-compile from inside a buildroot you always need to watch out that no includes and whatnot from the host system are added. So the pkg-config files need to be OK to use for cross-compile. For instance we use a pkg-config script which calls the real pkg-config like this: pkg-config.real --define-variable=prefix=${STAGING_PREFIX} --define-variable=exec_prefix=${STAGING_PREFIX} --define-variable=bindir=${STAGING_PREFIX}/bin $@ This way we update some variables commonly used in the .pc files. The default libpjproject.pc file that gets installed contains this: prefix=/usr exec_prefix=${prefix} libdir=/usr/lib includedir=/usr/include Name: libpjproject Description: Multimedia communication library URL: http://www.pjsip.org Version: 2.9 Libs: -L${libdir} -lpjsua2 -lpjsua -lpjsip-ua -lpjsip-simple -lpjsip -lpjmedia-codec -lpjmedia -lpjmedia-videodev -lpjmedia-audiodev -lpjmedia -lpjnath -lpjlib-util -lsrtp2 -lpj -lssl -lcrypto -luuid -lm -lrt -lpthread Cflags: -I${includedir} -I/usr/include -DPJ_AUTOCONF=1 -DPJ_IS_BIG_ENDIAN=1 -DPJ_IS_LITTLE_ENDIAN=0 -fPIC -I/home/sk/tmp/openwrt/staging_dir/target-mips_24kc_musl/usr/include So it contains a hardcoded libdir and includedir and also adds a hardcoded -I/usr/include into the CFLAGS. The attached patch fixes all that for us. I'm wondering if this can be included upstream? If not that's fine, happy to carry the patch locally. Kind regards, Seb