wiki:Yocto/NativeCompile

Native Compile

Native Compiling is when you build a program on the target device itself. This is different from using the SDK to compile on a host system and copy the binaries onto the target device. The goal of this page is to instruct how to install and use some of these developer tools on the target device.

Installing Developer Tools

To start, it is required to modify the base Yocto build on the desktop machine with the developer tools included in the build.

  1. Start by building the Yocto OS on the development desktop Yocto Building page
  2. There are several tools required to be installed from the Yocto build system to get the proper development tools for native compilation. The best way to build these packages into your image without having to edit the image.bb file itself is to edit the local.conf file instead in the build/conf/ directory.
    1. Edit the local.conf file in the build/conf/ directory on your desktop machine where the Yocto build is.
      1. The following lines are required to be added:
        IMAGE_FEATURES_append = " tools-sdk dev-pkgs "
        IMAGE_INSTALL_append = " kernel-dev git subversion "
        
      2. Adding the above lines to either your own image.bb or to the local.conf file will install many dev tools and linux headers. These include gcc, g++, make, autoconf, perl, git/svn, and many more totaling to roughly 90mb of extra disk space.
  1. After adding these lines, re-build the Yocto OS
  2. Flash the new .ubi to the Gateworks SBC

Compile C Program

To compile a simple hello world C application on the Gateworks SBC, please see the following example.

This will only work once the Installation of the Developer Tools above has been performed.

  1. First write a simple C application
    cat <<EOF > hello.c
    #include <stdio.h>
    
    int main(void) {
        puts("Hello, world!");
        return 0;
    }
    EOF
    
  1. Next, compile and run
    gcc hello.c -o hello_c
    ./hello_c
    

Compile C++ Program

To compile a simple hello world C++ application, please see the following example.

  1. First write a simple C++ application
    cat <<EOF > hello.cpp
    #include <iostream>
    
    int main() {
        std::cout << "Hello, world!" << std::endl;
        return 0;
    }
    EOF
    
  1. Next, compile and run
    g++ hello.cpp -o hello_cpp
    ./hello_cpp
    

Compile Using Make

This example will clone the gst-gateworks-apps project and compile it. Note that compiling this program requires that gstreamer-1.0 and gstreamer1.0-rtsp-server are installed which are included by default in the gateworks-image-multimedia image.

  1. First, get source code
    git clone https://github.com/Gateworks/gst-gateworks-apps.git
    cd gst-gateworks-apps
    
  1. Compile
    make
    

Binaries are stored in the bin/ directory.

Last modified 18 months ago Last modified on 03/08/16 13:57:24