Changes between Initial Version and Version 1 of Yocto/NativeCompile


Ignore:
Timestamp:
10/22/2017 05:28:45 AM (7 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Yocto/NativeCompile

    v1 v1  
     1{{{#!html
     2          <div id="wikipage" class="trac-content"><p>
     3</p><div class="wiki-toc">
     4<ol>
     5  <li>
     6    <a href="#NativeCompile">Native Compile</a>
     7    <ol>
     8      <li>
     9        <a href="#InstallingDeveloperTools">Installing Developer Tools</a>
     10      </li>
     11      <li>
     12        <a href="#CompileCProgram">Compile C Program</a>
     13      </li>
     14      <li>
     15        <a href="#CompileCProgram1">Compile C++ Program</a>
     16      </li>
     17      <li>
     18        <a href="#CompileUsingMake">Compile Using Make</a>
     19      </li>
     20    </ol>
     21  </li>
     22</ol>
     23</div><p>
     24</p>
     25<h1 id="NativeCompile">Native Compile</h1>
     26<p>
     27Native Compiling is when you build a program on the target device itself. This is different from using the <a class="wiki" href="/wiki/Yocto/SDK">SDK</a> 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.
     28</p>
     29<h2 id="InstallingDeveloperTools">Installing Developer Tools</h2>
     30<p>
     31To start, it is required to modify the base Yocto build on the desktop machine with the developer tools included in the build.
     32</p>
     33<ol><li>Start by building the Yocto OS on the development desktop <a class="wiki" href="/wiki/Yocto/Building">Yocto Building page</a>
     34</li><li>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 <tt>image.bb</tt> file itself is to edit the <tt>local.conf</tt> file instead in the <tt>build/conf/</tt> directory.
     35<ol><li>Edit the <tt>local.conf</tt> file in the <tt>build/conf/</tt> directory on your desktop machine where the Yocto build is.
     36<ol class="loweralpha"><li>The following lines are required to be added:
     37<div class="code"><pre><span class="nv">IMAGE_FEATURES_append</span> <span class="o">=</span> <span class="s2">" tools-sdk dev-pkgs "</span>
     38<span class="nv">IMAGE_INSTALL_append</span> <span class="o">=</span> <span class="s2">" kernel-dev git subversion "</span>
     39</pre></div></li><li>Adding the above lines to either your own <tt>image.bb</tt> or to the <tt>local.conf</tt> file will install many dev tools and linux headers. These include <tt>gcc</tt>, <tt>g++</tt>, <tt>make</tt>, <tt>autoconf</tt>, <tt>perl</tt>, <tt>git/svn</tt>, and many more totaling to roughly 90mb of extra disk space.
     40</li></ol></li></ol></li></ol><ol start="3"><li>After adding these lines, re-build the Yocto OS
     41</li><li>Flash the new .ubi to the Gateworks SBC
     42</li></ol><ul><li>Steps regarding building can be found on the main <a class="wiki" href="/wiki/Yocto/Building">Yocto Building page</a>
     43</li></ul><h2 id="CompileCProgram">Compile C Program</h2>
     44<p>
     45To compile a simple hello world C application on the Gateworks SBC, please see the following example.
     46</p>
     47<p>
     48This will only work once the Installation of the Developer Tools above has been performed.
     49</p>
     50<ol><li>First write a simple C application
     51<div class="code"><pre>cat <span class="s">&lt;&lt;EOF &gt; hello.c
     52#include &lt;stdio.h&gt;
     53
     54int main(void) {
     55    puts("Hello, world!");
     56    return 0;
     57}
     58EOF</span>
     59</pre></div></li></ol><ol start="2"><li>Next, compile and run
     60<div class="code"><pre>gcc hello.c -o hello_c
     61./hello_c
     62</pre></div></li></ol><h2 id="CompileCProgram1">Compile C++ Program</h2>
     63<p>
     64To compile a simple hello world C++ application, please see the following example.
     65</p>
     66<ol><li>First write a simple C++ application
     67<div class="code"><pre>cat <span class="s">&lt;&lt;EOF &gt; hello.cpp
     68#include &lt;iostream&gt;
     69
     70int main() {
     71    std::cout &lt;&lt; "Hello, world!" &lt;&lt; std::endl;
     72    return 0;
     73}
     74EOF</span>
     75</pre></div></li></ol><ol start="2"><li>Next, compile and run
     76<div class="code"><pre>g++ hello.cpp -o hello_cpp
     77./hello_cpp
     78</pre></div></li></ol><h2 id="CompileUsingMake">Compile Using Make</h2>
     79<p>
     80This example will clone the <tt>gst-gateworks-apps</tt> project and compile it. Note that compiling this program requires that <tt>gstreamer-1.0</tt> and <tt>gstreamer1.0-rtsp-server</tt> are installed which are included by default in the <tt>gateworks-image-multimedia</tt> image.
     81</p>
     82<ol><li>First, get source code
     83<div class="code"><pre>git clone https://github.com/Gateworks/gst-gateworks-apps.git
     84<span class="nb">cd </span>gst-gateworks-apps
     85</pre></div></li></ol><ol start="2"><li>Compile
     86<div class="code"><pre>make
     87</pre></div></li></ol><p>
     88Binaries are stored in the <tt>bin/</tt> directory.
     89</p>
     90}}}