Version 1 (modified by 7 years ago) ( diff ) | ,
---|
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.
- Start by building the Yocto OS on the development desktop Yocto Building page
- 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.
- Edit the local.conf file in the build/conf/ directory on your desktop machine where the Yocto build is.
- The following lines are required to be added:
IMAGE_FEATURES_append = " tools-sdk dev-pkgs " IMAGE_INSTALL_append = " kernel-dev git subversion "
- 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.
- The following lines are required to be added:
- Edit the local.conf file in the build/conf/ directory on your desktop machine where the Yocto build is.
- After adding these lines, re-build the Yocto OS
- Flash the new .ubi to the Gateworks SBC
- Steps regarding building can be found on the main Yocto Building page
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.
- First write a simple C application
cat <<EOF > hello.c #include <stdio.h> int main(void) { puts("Hello, world!"); return 0; } EOF
- 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.
- First write a simple C++ application
cat <<EOF > hello.cpp #include <iostream> int main() { std::cout << "Hello, world!" << std::endl; return 0; } EOF
- 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.
- First, get source code
git clone https://github.com/Gateworks/gst-gateworks-apps.git cd gst-gateworks-apps
- Compile
make
Binaries are stored in the bin/ directory.