# Obtaining the SDK

## Locating Pre-Built SDK Installers

You can use existing, pre-built toolchains by locating and running an SDK installer script that ships with the Yocto Project. Using this method, you select and download an architecture-specific SDK installer and then run the script to hand-install the toolchain.

You can find SDK installers here:

- Standard SDK Installers: Go to and find the folder that matches your host development system (i.e. `i686` for 32-bit machines or `x86_64` for 64-bit machines).

  Go into that folder and download the SDK installer whose name includes the appropriate target architecture. The toolchains provided by the Yocto Project are based off of the `core-image-sato` image and contain libraries appropriate for developing against that image. For example, if your host development system is a 64-bit x86 system and you are going to use your cross-toolchain for a 32-bit x86 target, go into the `x86_64` folder and download the following installer:

           poky-glibc-x86_64-core-image-sato-i586-toolchain-&DISTRO;.sh

- Extensible SDK Installers: Installers for the extensible SDK are also located in . These installers have the string `ext` as part of their names:

           poky-glibc-x86_64-core-image-sato-core2-64-toolchain-ext-&DISTRO;.sh

## Building an SDK Installer

As an alternative to locating and downloading a SDK installer, you can build the SDK installer assuming you have first sourced the environment setup script. See the "Building Images" section in the Yocto Project Quick Start for steps that show you how to set up the Yocto Project environment. In particular, you need to be sure the `MACHINE` variable matches the architecture for which you are building and that the `SDKMACHINE` variable is correctly set if you are building a toolchain designed to run on an architecture that differs from your current development host machine (i.e. the build machine).

To build the SDK installer for a standard SDK and populate the SDK image, use the following command:

         $ bitbake image -c populate_sdk

You can do the same for the extensible SDK using this command:

         $ bitbake image -c populate_sdk_ext

These commands result in a SDK installer that contains the sysroot that matches your target root filesystem.

When the `bitbake` command completes, the SDK installer will be in `tmp/deploy/sdk` in the Build Directory.

### Notes

- By default, this toolchain does not build static binaries. If you want to use the toolchain to build these types of libraries, you need to be sure your SDK has the appropriate static development libraries. Use the `TOOLCHAIN_TARGET_TASK` variable inside your `local.conf` file to install the appropriate library packages in the SDK. Following is an example using `libc` static development libraries:

           TOOLCHAIN_TARGET_TASK_append = " libc-staticdev"

- For additional information on building the installer, see the Cookbook guide to Making an Eclipse Debug Capable Image wiki page.

## Extracting the Root Filesystem

After installing the toolchain, for some use cases you might need to separately extract a root filesystem:

- You want to boot the image using NFS.

- You want to use the root filesystem as the target sysroot. For example, the Eclipse IDE environment with the Eclipse Yocto Plug-in installed allows you to use QEMU to boot under NFS.

- You want to develop your target application using the root filesystem as the target sysroot.

To extract the root filesystem, first `source` the cross-development environment setup script to establish necessary environment variables. If you built the toolchain in the Build Directory, you will find the toolchain environment script in the `tmp` directory. If you installed the toolchain by hand, the environment setup script is located in `/opt/poky/&DISTRO;`.

After sourcing the environment script, use the `runqemu-extract-sdk` command and provide the filesystem image.

Following is an example. The second command sets up the environment. In this case, the setup script is located in the `/opt/poky/&DISTRO;` directory. The third command extracts the root filesystem from a previously built filesystem that is located in the `~/Downloads` directory. Furthermore, this command extracts the root filesystem into the `qemux86-sato` directory:

         $ cd ~
         $ source /opt/poky/&DISTRO;/environment-setup-i586-poky-linux
         $ runqemu-extract-sdk \
            ~/Downloads/core-image-sato-sdk-qemux86-2011091411831.rootfs.tar.bz2 \
            $HOME/qemux86-sato

You could now point to the target sysroot at `qemux86-sato`.

## Installed Standard SDK Directory Structure

The following figure shows the resulting directory structure after you install the Standard SDK by running the `*.sh` SDK installation script:

The installed SDK consists of an environment setup script for the SDK, a configuration file for the target, a version file for the target, and the root filesystem (`sysroots`) needed to develop objects for the target system.

Within the figure, italicized text is used to indicate replaceable portions of the file or directory name. For example, install_dir/version is the directory where the SDK is installed. By default, this directory is `/opt/poky/`. And, version represents the specific snapshot of the SDK (e.g. `&DISTRO;`). Furthermore, target represents the target architecture (e.g. `i586`) and host represents the development system's architecture (e.g. `x86_64`). Thus, the complete names of the two directories within the `sysroots` could be `i586-poky-linux` and `x86_64-pokysdk-linux` for the target and host, respectively.

## Installed Extensible SDK Directory Structure

The following figure shows the resulting directory structure after you install the Extensible SDK by running the `*.sh` SDK installation script:

The installed directory structure for the extensible SDK is quite different than the installed structure for the standard SDK. The extensible SDK does not separate host and target parts in the same manner as does the standard SDK. The extensible SDK uses an embedded copy of the OpenEmbedded build system, which has its own sysroots.

Of note in the directory structure are an environment setup script for the SDK, a configuration file for the target, a version file for the target, and a log file for the OpenEmbedded build system preparation script run by the installer.

Within the figure, italicized text is used to indicate replaceable portions of the file or directory name. For example, install_dir is the directory where the SDK is installed, which is `poky_sdk` by default. target represents the target architecture (e.g. `i586`) and host represents the development system's architecture (e.g. `x86_64`).