Home » Development and Build » Yocto Embedded Linux » How to build target and host Sysroot with yocto / poky ?

How to build target and host Sysroot with yocto / poky ?

If you want to build some external packages which are using sysroot within yocto framework or buildsystem, you will first need to build the sysroot which you can then link with the package during compilation.

The matching target sysroot contains needed headers and libraries for generating binaries that run on the target architecture. The sysroot is based on the target root filesystem image that is built by the OpenEmbedded build system and uses the same Metadata configuration used to build the cross-toolchain.

Similarly host sysroot contains the prerequisite binaries, headers and libraries which are required to build target sysroot

For building host and target sysroots with yocto, follow below mentioned steps. This article assumes, you already have development environment setup for yocto, if not please read and setup as per “Building Yocto for Raspberry Pi / Creating Embedded Linux for RPi using Yocto”

 $ git clone git://git.openembedded.org/openembedded-core
$ cd openembedded-core/
$ git checkout -b thud origin/thud
$ cd poky
$ source oe-init-build-env

Update local.conf to add openembedded-core layer which contains recipes for compiling sysroot

$ vim conf/bblayers.conf
  /home/myuser/workspace/openembedded-core \
  /home/myuser/workspace/poky \
$ bitbake build-sysroots

Once the compilation gets over, you can see the target sysroot at, build/tmp/sysroots/MACHINE e.g. build/tmp/sysroots/raspberrypi3 if you have compiled for raspberrypi3 and host sysroot is available at build/tmp/sysroots/x86_64

If you want to use these sysroots for building some source, as mentioned earlier, you can use following arguments as,

STAGING_DIR_TARGET for accessing target sysroot, STAGING_DIR_NATIVE for accessing host sysroot

example : –target-sysroot=${STAGING_DIR_TARGET}

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment