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:// 
 $ 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 
 BBLAYERS ?= " \
  /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}

Android Android Commands Android Java Applications Application Libraries Application Stack / User Interface Bash / Shell Scripts Commands and Packages Compilation Content Management System - CMS Core Kernel C Programs Development & Build Development Environment Setup Errors & Failures Flutter git Go Language Programs Hardware Platforms HTML JAVA Programs Kernel & Device Drivers Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Monetization / Google AdSense NDK / Middleware / HAL OS Concepts PHP Programming Languages RaspberryPi Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Socurce Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized User Interface Userspace Utilities Web design and development Wordpress Yocto / Bitbake / Openembedded

Leave a Reply / Ask Question