How to Build Target Application in the Host Machine

From Yocto Project
Jump to navigationJump to search

Build target app in host machine

If you want to build your target application in host machine just by command line, you can refer to the following example:

1. Create a file, named setup-cross-environment

This file can be got by "bitbake meta-ide-support", or you can refer to the following as an example. You should modify "/sda1/poky-20100903/build-qemuppc-gcc" to your own poky build path, besides you should modify the sysroot path to fit your own cross architecture. The example is for powerpc.

export PATH=/sda1/poky-20100903/build-qemuppc-gcc/tmp/sysroots/i686-linux/usr/bin/ppc603e-poky-linux:/sda1/poky-20100903/build-
qemuppc-gcc/tmp/sysroots/ppc603e-poky-linux/usr/bin/crossscripts:/sda1/poky-20100903/build-qemuppc-gcc/tmp/sysroots/i686-
linux/usr/sbin:/sda1/poky-20100903/build-qemuppc-gcc/tmp/sysroots/i686-linux/usr/bin:/sda1/poky-20100903/build-qemuppc-
gcc/tmp/sysroots/i686-linux/sbin:/sda1/poky-20100903/build-qemuppc-gcc/tmp/sysroots/i686-
linux//bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

export PKG_CONFIG_SYSROOT_DIR=/sda1/poky-20100903/build-qemuppc-gcc/tmp/sysroots/ppc603e-poky-linux
export PKG_CONFIG_PATH=/sda1/poky-20100903/build-qemuppc-gcc/tmp/sysroots/ppc603e-poky-linux/usr/lib/pkgconfig
export CONFIG_SITE="/sda1/poky-20100903/meta/site/endian-little /sda1/poky-20100903/meta/site/common-glibc /sda1/poky-
20100903/meta/site/ix86-common /sda1/poky-20100903/meta/site/common"
export CC=powerpc-poky-linux-gcc
export CXX=powerpc-poky-linux-g++
export CONFIGURE_FLAGS="--target=powerpc-poky-linux --host=powerpc-poky-linux --build=i686-linux"

2. Source the file

# source setup-cross-environment

3. Configure the target application

If your target application is autotool based, you should run configure like:

# ./configure --target=powerpc-poky-linux --host=powerpc-poky-linux --build=i686-linux

4. Build the target application

# make

5. Copy the application binary into target system