This check-list tries to document the obvious, to reduce the time spent fixing toolchain related errors while cross compiling.
- Export the toolchain location to the
PATHenvironment variable - Set proper
--sysrootforCFLAGS,CXXFLAGSandLDFLAGS - Set proper
PKG_CONFIG_SYSROOT_DIR,PKG_CONFIG_PATHandPKG_CONFIG_LIBDIRforpkg-configtool. This is important for build scripts which usepkg-configto determine the proper build flags.
Note: Use pkg-config >= 0.26 . There is bug with previous versions of pkg-config which ignores the PKG_CONFIG_SYSROOT_DIR value
A sample configuration
export __CB_TOOLCHAIN_DIR=/opt/cross-toolchain
export __CB_TOOLCHAIN_SYSROOT=${__CB_TOOLCHAIN_DIR}/sysroot
export PATH=${__CB_TOOLCHAIN_DIR}/bin:${PATH}
export PKG_CONFIG_SYSROOT_DIR=${__CB_TOOLCHAIN_SYSROOT}
export PKG_CONFIG_PATH=${PKG_CONFIG_SYSROOT_DIR}/usr/lib/pkgconfig
export PKG_CONFIG_LIBDIR=${PKG_CONFIG_SYSROOT_DIR}/usr/lib/pkgconfig
export CFLAGS+="--sysroot=${__CB_TOOLCHAIN_SYSROOT} "
export CXXFLAGS+="--sysroot=${__CB_TOOLCHAIN_SYSROOT} "
export LDFLAGS+="--sysroot=${__CB_TOOLCHAIN_SYSROOT} "
#export PKG_CONFIG_DEBUG_SPEW=true # this one is for debugging pkg-config
Note : Need to update the post on how to cross compile packages which use autoconf tools