<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.yoctoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Alex+Lennon</id>
	<title>Yocto Project - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.yoctoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Alex+Lennon"/>
	<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/Special:Contributions/Alex_Lennon"/>
	<updated>2026-04-23T06:34:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Releases&amp;diff=28250</id>
		<title>Releases</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Releases&amp;diff=28250"/>
		<updated>2017-06-25T17:23:13Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update release name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- keywords: release names codenames versions version names numbers branches branch --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Release Activity==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
!Codename&lt;br /&gt;
!Yocto Project Version&lt;br /&gt;
!Release Date&lt;br /&gt;
!Current Version&lt;br /&gt;
!Support Level&lt;br /&gt;
!Poky Version&lt;br /&gt;
!BitBake branch&lt;br /&gt;
|-&lt;br /&gt;
|Rocko&lt;br /&gt;
|2.4&lt;br /&gt;
|Fall 2017&lt;br /&gt;
|&lt;br /&gt;
|Development&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Pyro&lt;br /&gt;
|2.3&lt;br /&gt;
|May 2017&lt;br /&gt;
|2.3.0&lt;br /&gt;
|Stable&lt;br /&gt;
|17.0&lt;br /&gt;
|1.34&lt;br /&gt;
|-&lt;br /&gt;
|Morty&lt;br /&gt;
|2.2&lt;br /&gt;
|Nov 2016&lt;br /&gt;
|2.2.1&lt;br /&gt;
|Stable&lt;br /&gt;
|16.0&lt;br /&gt;
|1.32&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|Krogoth&lt;br /&gt;
|2.1&lt;br /&gt;
|Apr 2016&lt;br /&gt;
|2.1.2&lt;br /&gt;
|Stable&lt;br /&gt;
|15.0&lt;br /&gt;
|1.30&lt;br /&gt;
|-&lt;br /&gt;
|Jethro&lt;br /&gt;
|2.0&lt;br /&gt;
|Nov 2015&lt;br /&gt;
|2.0.3&lt;br /&gt;
|Community&lt;br /&gt;
|14.0&lt;br /&gt;
|1.28&lt;br /&gt;
|-&lt;br /&gt;
|Fido&lt;br /&gt;
|1.8&lt;br /&gt;
|Apr 2015&lt;br /&gt;
|1.8.2&lt;br /&gt;
|Community&lt;br /&gt;
|13.0&lt;br /&gt;
|1.26&lt;br /&gt;
|-&lt;br /&gt;
|Dizzy&lt;br /&gt;
|1.7&lt;br /&gt;
|Oct 2014&lt;br /&gt;
|1.7.3&lt;br /&gt;
|Community&lt;br /&gt;
|12.0&lt;br /&gt;
|1.24&lt;br /&gt;
|-&lt;br /&gt;
|Daisy&lt;br /&gt;
|1.6&lt;br /&gt;
|Apr 2014&lt;br /&gt;
|1.6.3&lt;br /&gt;
|Community&lt;br /&gt;
|11.0&lt;br /&gt;
|1.22&lt;br /&gt;
|-&lt;br /&gt;
|Dora&lt;br /&gt;
|1.5&lt;br /&gt;
|Oct 2013&lt;br /&gt;
|1.5.4&lt;br /&gt;
|Community&lt;br /&gt;
|10.0&lt;br /&gt;
|1.20&lt;br /&gt;
|-&lt;br /&gt;
|Dylan&lt;br /&gt;
|1.4&lt;br /&gt;
|Apr 2013&lt;br /&gt;
|1.4.3[https://lists.yoctoproject.org/pipermail/yocto/2014-July/020699.html *]&lt;br /&gt;
|Community&lt;br /&gt;
|9.0&lt;br /&gt;
|1.18&lt;br /&gt;
|-&lt;br /&gt;
|Danny&lt;br /&gt;
|1.3&lt;br /&gt;
|Oct 2012&lt;br /&gt;
|1.3.2&lt;br /&gt;
|Community&lt;br /&gt;
|8.0&lt;br /&gt;
|1.16&lt;br /&gt;
|-&lt;br /&gt;
|Denzil&lt;br /&gt;
|1.2&lt;br /&gt;
|Apr 2012&lt;br /&gt;
|1.2.2&lt;br /&gt;
|Community&lt;br /&gt;
|7.0&lt;br /&gt;
|1.15&lt;br /&gt;
|-&lt;br /&gt;
|Edison&lt;br /&gt;
|1.1&lt;br /&gt;
|Oct 2011?&lt;br /&gt;
|1.1.2&lt;br /&gt;
|Community&lt;br /&gt;
|6.0&lt;br /&gt;
|1.13&lt;br /&gt;
|-&lt;br /&gt;
|Bernard&lt;br /&gt;
|1.0&lt;br /&gt;
|??? 2011?&lt;br /&gt;
|1.0.2&lt;br /&gt;
|Community&lt;br /&gt;
|5.0&lt;br /&gt;
|1.11&lt;br /&gt;
|-&lt;br /&gt;
|Laverne&lt;br /&gt;
|0.9&lt;br /&gt;
|??? 2010?&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|4.0&lt;br /&gt;
|1.11&lt;br /&gt;
|-&lt;br /&gt;
|Purple&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|3.2&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Pinky&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|3.1&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Blinky&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|3.0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Clyde&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|2.0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Inky&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|1.0&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; see also [[Stable branch maintenance]], [[Linux Yocto]], [[Planning]] and [[Release Feature Table]] pages.&lt;br /&gt;
&lt;br /&gt;
== Releases Links==&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Yocto Project Release&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Code Name&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Poky version&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Maintainer&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Features&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Schedule&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Status&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;QA Test Plan&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;QA Test Report&#039;&#039;&#039;&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.4&lt;br /&gt;
| Rocko&lt;br /&gt;
| 18.0&lt;br /&gt;
| Richard Purdie&lt;br /&gt;
| [[Yocto_2.4_Features]]&lt;br /&gt;
| [[Yocto_2.4_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.4_Status]]&lt;br /&gt;
| [[Yocto_Project_2.4_Release_Test_Plan | Yocto_2.4_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_Project_2.4_Release_Test_Plan#Execution_History | 2.4 qa run history]]&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.3&lt;br /&gt;
| Pyro&lt;br /&gt;
| 17.0&lt;br /&gt;
| Richard Purdie&lt;br /&gt;
| [[Yocto_2.3_Features]]&lt;br /&gt;
| [[Yocto_2.3_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.3_Status]]&lt;br /&gt;
| [[Yocto_Project_2.3_Release_Test_Plan | Yocto_2.3_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_Project_2.3_Release_Test_Plan#Execution_History | 2.3 qa run history]]&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.2&lt;br /&gt;
| Morty&lt;br /&gt;
| 16.0&lt;br /&gt;
| Armin Kuster&lt;br /&gt;
| [[Yocto_2.2_Features]]&lt;br /&gt;
| [[Yocto_2.2_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.2_Status]]&lt;br /&gt;
| [[Yocto_2.2_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_Project_2.2_Release_Test_Plan#Execution_History | 2.2 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.1&lt;br /&gt;
| Krogoth&lt;br /&gt;
| 15.0&lt;br /&gt;
| Armin Kuster&lt;br /&gt;
| [[Yocto_2.1_Features]]&lt;br /&gt;
| [[Yocto_2.1_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.1_Status]]&lt;br /&gt;
| [[Yocto_2.1_Overall_Test_Plan]]&lt;br /&gt;
| [[2.1 qa run history]] &lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.0&lt;br /&gt;
| Jethro&lt;br /&gt;
| 14.0&lt;br /&gt;
| Robert Yang&lt;br /&gt;
| [[Yocto_1.9_Features]]&lt;br /&gt;
| [[Yocto_1.9_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.9_Status]]&lt;br /&gt;
| &lt;br /&gt;
| [[1.9 qa run history]] &lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 1.8&lt;br /&gt;
| Fido&lt;br /&gt;
| 13.0&lt;br /&gt;
| Joshua Lock&lt;br /&gt;
| [[Yocto_1.8_Features]]&lt;br /&gt;
| [[Yocto_1.8_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.8_Status]]&lt;br /&gt;
| [[Yocto_1.8_Overall_Test_Plan]]&lt;br /&gt;
| [[1.8 qa run history]] &lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.7&lt;br /&gt;
| Dizzy&lt;br /&gt;
| 12.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.7_Features]]&lt;br /&gt;
| [[Yocto_1.7_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.7_Status]]&lt;br /&gt;
| [[Yocto_1.7_Overall_Test_Plan]]&lt;br /&gt;
| [[1.7 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.6&lt;br /&gt;
| Daisy&lt;br /&gt;
| 11.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.6_Features]]&lt;br /&gt;
| [[Yocto_1.6_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.6_Status]]&lt;br /&gt;
| [[Yocto_1.6_Overall_Test_Plan]]&lt;br /&gt;
| [[1.6 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.5&lt;br /&gt;
| Dora&lt;br /&gt;
| 10.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.5_Features]]&lt;br /&gt;
| [[Yocto_1.5_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.5_Status]]&lt;br /&gt;
| [[Yocto_1.5_Overall_Test_Plan]]&lt;br /&gt;
| [[1.5 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.4&lt;br /&gt;
| Dylan&lt;br /&gt;
| 9.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.4_Features]]&lt;br /&gt;
| [[Yocto_1.4_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.4_Status]]&lt;br /&gt;
| [[Yocto_1.4_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.4_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.3&lt;br /&gt;
| Danny&lt;br /&gt;
| 8.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.3_Features]]&lt;br /&gt;
| [[Yocto_1.3_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.3_Status]]&lt;br /&gt;
| [[Yocto_1.3_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.3_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.2&lt;br /&gt;
| Denzil&lt;br /&gt;
| 7.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.2_Features]]&lt;br /&gt;
| [[Yocto_1.2_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.2_Status]]&lt;br /&gt;
| [[Yocto_1.2_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.2_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.1&lt;br /&gt;
| Edison&lt;br /&gt;
| 6.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.1_Features]]&lt;br /&gt;
| [[Yocto_1.1_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.1_Release_Criteria]]&lt;br /&gt;
| [[Yocto_1.1_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.1_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.0&lt;br /&gt;
| Bernard&lt;br /&gt;
| 5.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_Features]]&lt;br /&gt;
| [[Yocto_1.0_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.0_Release_Criteria]]&lt;br /&gt;
| [[Yocto_1.0_Overall_Test_Plan]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Releases&amp;diff=28249</id>
		<title>Releases</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Releases&amp;diff=28249"/>
		<updated>2017-06-25T17:22:49Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update release name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- keywords: release names codenames versions version names numbers branches branch --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Release Activity==&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; border=&amp;quot;2&amp;quot;&lt;br /&gt;
!Codename&lt;br /&gt;
!Yocto Project Version&lt;br /&gt;
!Release Date&lt;br /&gt;
!Current Version&lt;br /&gt;
!Support Level&lt;br /&gt;
!Poky Version&lt;br /&gt;
!BitBake branch&lt;br /&gt;
|-&lt;br /&gt;
|Rocky&lt;br /&gt;
|2.4&lt;br /&gt;
|Fall 2017&lt;br /&gt;
|&lt;br /&gt;
|Development&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Pyro&lt;br /&gt;
|2.3&lt;br /&gt;
|May 2017&lt;br /&gt;
|2.3.0&lt;br /&gt;
|Stable&lt;br /&gt;
|17.0&lt;br /&gt;
|1.34&lt;br /&gt;
|-&lt;br /&gt;
|Morty&lt;br /&gt;
|2.2&lt;br /&gt;
|Nov 2016&lt;br /&gt;
|2.2.1&lt;br /&gt;
|Stable&lt;br /&gt;
|16.0&lt;br /&gt;
|1.32&lt;br /&gt;
|-&lt;br /&gt;
|-&lt;br /&gt;
|Krogoth&lt;br /&gt;
|2.1&lt;br /&gt;
|Apr 2016&lt;br /&gt;
|2.1.2&lt;br /&gt;
|Stable&lt;br /&gt;
|15.0&lt;br /&gt;
|1.30&lt;br /&gt;
|-&lt;br /&gt;
|Jethro&lt;br /&gt;
|2.0&lt;br /&gt;
|Nov 2015&lt;br /&gt;
|2.0.3&lt;br /&gt;
|Community&lt;br /&gt;
|14.0&lt;br /&gt;
|1.28&lt;br /&gt;
|-&lt;br /&gt;
|Fido&lt;br /&gt;
|1.8&lt;br /&gt;
|Apr 2015&lt;br /&gt;
|1.8.2&lt;br /&gt;
|Community&lt;br /&gt;
|13.0&lt;br /&gt;
|1.26&lt;br /&gt;
|-&lt;br /&gt;
|Dizzy&lt;br /&gt;
|1.7&lt;br /&gt;
|Oct 2014&lt;br /&gt;
|1.7.3&lt;br /&gt;
|Community&lt;br /&gt;
|12.0&lt;br /&gt;
|1.24&lt;br /&gt;
|-&lt;br /&gt;
|Daisy&lt;br /&gt;
|1.6&lt;br /&gt;
|Apr 2014&lt;br /&gt;
|1.6.3&lt;br /&gt;
|Community&lt;br /&gt;
|11.0&lt;br /&gt;
|1.22&lt;br /&gt;
|-&lt;br /&gt;
|Dora&lt;br /&gt;
|1.5&lt;br /&gt;
|Oct 2013&lt;br /&gt;
|1.5.4&lt;br /&gt;
|Community&lt;br /&gt;
|10.0&lt;br /&gt;
|1.20&lt;br /&gt;
|-&lt;br /&gt;
|Dylan&lt;br /&gt;
|1.4&lt;br /&gt;
|Apr 2013&lt;br /&gt;
|1.4.3[https://lists.yoctoproject.org/pipermail/yocto/2014-July/020699.html *]&lt;br /&gt;
|Community&lt;br /&gt;
|9.0&lt;br /&gt;
|1.18&lt;br /&gt;
|-&lt;br /&gt;
|Danny&lt;br /&gt;
|1.3&lt;br /&gt;
|Oct 2012&lt;br /&gt;
|1.3.2&lt;br /&gt;
|Community&lt;br /&gt;
|8.0&lt;br /&gt;
|1.16&lt;br /&gt;
|-&lt;br /&gt;
|Denzil&lt;br /&gt;
|1.2&lt;br /&gt;
|Apr 2012&lt;br /&gt;
|1.2.2&lt;br /&gt;
|Community&lt;br /&gt;
|7.0&lt;br /&gt;
|1.15&lt;br /&gt;
|-&lt;br /&gt;
|Edison&lt;br /&gt;
|1.1&lt;br /&gt;
|Oct 2011?&lt;br /&gt;
|1.1.2&lt;br /&gt;
|Community&lt;br /&gt;
|6.0&lt;br /&gt;
|1.13&lt;br /&gt;
|-&lt;br /&gt;
|Bernard&lt;br /&gt;
|1.0&lt;br /&gt;
|??? 2011?&lt;br /&gt;
|1.0.2&lt;br /&gt;
|Community&lt;br /&gt;
|5.0&lt;br /&gt;
|1.11&lt;br /&gt;
|-&lt;br /&gt;
|Laverne&lt;br /&gt;
|0.9&lt;br /&gt;
|??? 2010?&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|4.0&lt;br /&gt;
|1.11&lt;br /&gt;
|-&lt;br /&gt;
|Purple&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|3.2&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Pinky&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|3.1&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Blinky&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|3.0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Clyde&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|2.0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Inky&lt;br /&gt;
|N/A&lt;br /&gt;
|??? ????&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|1.0&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; see also [[Stable branch maintenance]], [[Linux Yocto]], [[Planning]] and [[Release Feature Table]] pages.&lt;br /&gt;
&lt;br /&gt;
== Releases Links==&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; {{table}}&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Yocto Project Release&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Code Name&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Poky version&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Maintainer&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Features&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Schedule&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;Status&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;QA Test Plan&#039;&#039;&#039;&lt;br /&gt;
| align=&amp;quot;center&amp;quot; style=&amp;quot;background:#f0f0f0;&amp;quot;|&#039;&#039;&#039;QA Test Report&#039;&#039;&#039;&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.4&lt;br /&gt;
| Rocko&lt;br /&gt;
| 18.0&lt;br /&gt;
| Richard Purdie&lt;br /&gt;
| [[Yocto_2.4_Features]]&lt;br /&gt;
| [[Yocto_2.4_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.4_Status]]&lt;br /&gt;
| [[Yocto_Project_2.4_Release_Test_Plan | Yocto_2.4_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_Project_2.4_Release_Test_Plan#Execution_History | 2.4 qa run history]]&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.3&lt;br /&gt;
| Pyro&lt;br /&gt;
| 17.0&lt;br /&gt;
| Richard Purdie&lt;br /&gt;
| [[Yocto_2.3_Features]]&lt;br /&gt;
| [[Yocto_2.3_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.3_Status]]&lt;br /&gt;
| [[Yocto_Project_2.3_Release_Test_Plan | Yocto_2.3_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_Project_2.3_Release_Test_Plan#Execution_History | 2.3 qa run history]]&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.2&lt;br /&gt;
| Morty&lt;br /&gt;
| 16.0&lt;br /&gt;
| Armin Kuster&lt;br /&gt;
| [[Yocto_2.2_Features]]&lt;br /&gt;
| [[Yocto_2.2_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.2_Status]]&lt;br /&gt;
| [[Yocto_2.2_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_Project_2.2_Release_Test_Plan#Execution_History | 2.2 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.1&lt;br /&gt;
| Krogoth&lt;br /&gt;
| 15.0&lt;br /&gt;
| Armin Kuster&lt;br /&gt;
| [[Yocto_2.1_Features]]&lt;br /&gt;
| [[Yocto_2.1_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v2.1_Status]]&lt;br /&gt;
| [[Yocto_2.1_Overall_Test_Plan]]&lt;br /&gt;
| [[2.1 qa run history]] &lt;br /&gt;
|-&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 2.0&lt;br /&gt;
| Jethro&lt;br /&gt;
| 14.0&lt;br /&gt;
| Robert Yang&lt;br /&gt;
| [[Yocto_1.9_Features]]&lt;br /&gt;
| [[Yocto_1.9_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.9_Status]]&lt;br /&gt;
| &lt;br /&gt;
| [[1.9 qa run history]] &lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
| Yocto Project 1.8&lt;br /&gt;
| Fido&lt;br /&gt;
| 13.0&lt;br /&gt;
| Joshua Lock&lt;br /&gt;
| [[Yocto_1.8_Features]]&lt;br /&gt;
| [[Yocto_1.8_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.8_Status]]&lt;br /&gt;
| [[Yocto_1.8_Overall_Test_Plan]]&lt;br /&gt;
| [[1.8 qa run history]] &lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.7&lt;br /&gt;
| Dizzy&lt;br /&gt;
| 12.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.7_Features]]&lt;br /&gt;
| [[Yocto_1.7_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.7_Status]]&lt;br /&gt;
| [[Yocto_1.7_Overall_Test_Plan]]&lt;br /&gt;
| [[1.7 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.6&lt;br /&gt;
| Daisy&lt;br /&gt;
| 11.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.6_Features]]&lt;br /&gt;
| [[Yocto_1.6_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.6_Status]]&lt;br /&gt;
| [[Yocto_1.6_Overall_Test_Plan]]&lt;br /&gt;
| [[1.6 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.5&lt;br /&gt;
| Dora&lt;br /&gt;
| 10.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.5_Features]]&lt;br /&gt;
| [[Yocto_1.5_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.5_Status]]&lt;br /&gt;
| [[Yocto_1.5_Overall_Test_Plan]]&lt;br /&gt;
| [[1.5 qa run history]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.4&lt;br /&gt;
| Dylan&lt;br /&gt;
| 9.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.4_Features]]&lt;br /&gt;
| [[Yocto_1.4_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.4_Status]]&lt;br /&gt;
| [[Yocto_1.4_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.4_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.3&lt;br /&gt;
| Danny&lt;br /&gt;
| 8.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.3_Features]]&lt;br /&gt;
| [[Yocto_1.3_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.3_Status]]&lt;br /&gt;
| [[Yocto_1.3_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.3_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.2&lt;br /&gt;
| Denzil&lt;br /&gt;
| 7.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.2_Features]]&lt;br /&gt;
| [[Yocto_1.2_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.2_Status]]&lt;br /&gt;
| [[Yocto_1.2_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.2_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.1&lt;br /&gt;
| Edison&lt;br /&gt;
| 6.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_1.1_Features]]&lt;br /&gt;
| [[Yocto_1.1_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.1_Release_Criteria]]&lt;br /&gt;
| [[Yocto_1.1_Overall_Test_Plan]]&lt;br /&gt;
| [[Yocto_1.1_Milestone_Test_Report]]&lt;br /&gt;
|-&lt;br /&gt;
| Yocto Project 1.0&lt;br /&gt;
| Bernard&lt;br /&gt;
| 5.0&lt;br /&gt;
| Community&lt;br /&gt;
| [[Yocto_Features]]&lt;br /&gt;
| [[Yocto_1.0_Schedule]]&lt;br /&gt;
| [[Yocto_Project_v1.0_Release_Criteria]]&lt;br /&gt;
| [[Yocto_1.0_Overall_Test_Plan]]&lt;br /&gt;
| &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17689</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17689"/>
		<updated>2016-02-23T09:57:22Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu [http://releases.ubuntu.com/14.04.4 14.04.4 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 14.04.4 LTS this will install Mono version 3.2.8 which is now quite old&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
Currently this will also install Mono 3.2.8 but may in future provide newer builds.&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure --enable-winformdemo&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Lastly you can run a test GTK# application with&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldgtk.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldgtk&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17688</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17688"/>
		<updated>2016-02-23T09:55:52Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu [http://releases.ubuntu.com/14.04.4 14.04.4 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 14.04.4 LTS this will install Mono version 3.2.8 which is now quite old&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
Currently this will also install Mono 3.2.8 but may in future provide newer builds.&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
Lastly you can run a test GTK# application with&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldgtk.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldgtk&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17687</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17687"/>
		<updated>2016-02-23T09:53:34Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu [http://releases.ubuntu.com/14.04.4 14.04.4 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 14.04.4 LTS this will install Mono version 3.2.8 which is now quite old&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
Currently this will also install Mono 3.2.8 but may in future provide newer builds.&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17686</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17686"/>
		<updated>2016-02-23T09:53:16Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu [http://releases.ubuntu.com/14.04.4 14.04.4 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 14.04.4 LTS this will install Mono version 3.2.8 which is now quite old&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
Currently this will also install Mono 3.2.8 but may in future provide newer builds.&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17685</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17685"/>
		<updated>2016-02-23T09:53:01Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu [http://releases.ubuntu.com/14.04.4 14.04.4 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 14.04.4 LTS this will install Mono version 3.2.8 which is now quite old&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
Currently this will also install Mono 3.2.8 but may in future provide newer builds.&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17684</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17684"/>
		<updated>2016-02-23T09:48:02Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu [http://releases.ubuntu.com/14.04.4 14.04.4 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 14.04.4 LTS this will install Mono version 3.2.8 which is now quite old&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
Currently this will also install Mono 3.2.8 but may in future provide newer builds.&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17683</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=17683"/>
		<updated>2016-02-23T09:46:52Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu [http://releases.ubuntu.com/14.04.4 14.04.4 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17679</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17679"/>
		<updated>2016-02-22T15:01:09Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17678</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17678"/>
		<updated>2016-02-22T15:00:47Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17677</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17677"/>
		<updated>2016-02-22T15:00:28Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17676</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17676"/>
		<updated>2016-02-22T15:00:08Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17675</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17675"/>
		<updated>2016-02-22T14:59:28Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Testing the example on an emulated target */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17674</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17674"/>
		<updated>2016-02-22T14:58:45Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17673</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17673"/>
		<updated>2016-02-22T14:58:12Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Build an example package based on a local source archive */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17672</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17672"/>
		<updated>2016-02-22T14:56:46Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Build an example package based on a remote source archive */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17671</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17671"/>
		<updated>2016-02-22T14:54:06Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* The bbexample recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17670</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17670"/>
		<updated>2016-02-22T14:53:08Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17669</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17669"/>
		<updated>2016-02-22T14:51:33Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17668</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17668"/>
		<updated>2016-02-22T14:50:44Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample &lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17667</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17667"/>
		<updated>2016-02-22T14:50:12Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample &lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17666</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17666"/>
		<updated>2016-02-22T14:48:46Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample &lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17665</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17665"/>
		<updated>2016-02-22T14:47:11Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample &lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17664</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17664"/>
		<updated>2016-02-22T14:46:32Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Update to Jethro&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 2.0 (Jethro) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
                &lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample &lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17663</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=17663"/>
		<updated>2016-02-22T10:11:50Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: change directory into yocto&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
                &lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample &lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=13031</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=13031"/>
		<updated>2014-06-19T09:59:01Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Add note on requirement for autoconf&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
In addition, if you wish to build the example on the host, outside Yocto, you will need autoconf installed&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process.&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12967</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12967"/>
		<updated>2014-05-23T11:20:25Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Cleanup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:88c6d5f1961d58b3ec203ff19594f954c3e49cd9&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
  do_install() {&lt;br /&gt;
          install -d &amp;quot;${D}${bindir}&amp;quot;&lt;br /&gt;
          install -d &amp;quot;${D}${libdir}/helloworld/.debug&amp;quot;&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
          install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
  &lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
          install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
          sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform  &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12966</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12966"/>
		<updated>2014-05-23T10:31:50Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Updated meta-mono commit hash&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:6d6f7377ec0d9a6acd87f111cde65c98b766e4c3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
 do_install() {&lt;br /&gt;
         mkdir -p ${D}${bindir}&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld/.debug  &lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=12891</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=12891"/>
		<updated>2014-05-18T12:13:14Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Updated as I am now using release archives from GitHub not auto-geneated archives as I am informed the checksums of these can change&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
                &lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample &lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-daisy-11.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-daisy-11.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12806</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12806"/>
		<updated>2014-05-11T09:38:31Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an xbuild recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
 do_install() {&lt;br /&gt;
         mkdir -p ${D}${bindir}&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld/.debug  &lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12805</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12805"/>
		<updated>2014-05-11T09:38:04Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an autotools recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive Building your own recipes from first principles] and the [https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide Recipe &amp;amp; Style Patch Guide].&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
 do_install() {&lt;br /&gt;
         mkdir -p ${D}${bindir}&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld/.debug  &lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12804</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12804"/>
		<updated>2014-05-11T09:35:58Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an xbuild recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive here]&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
 do_install() {&lt;br /&gt;
         mkdir -p ${D}${bindir}&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld/.debug  &lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12803</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12803"/>
		<updated>2014-05-11T09:35:41Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an xbuild recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive here]&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; recipe is similar to the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; recipe above, excepting that we override a couple of methods to ensure &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; runs as we wish it too&lt;br /&gt;
&lt;br /&gt;
This recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld-xbuild_1.1.bb here].&lt;br /&gt;
&lt;br /&gt;
First we include the definitions in the include file, and set the version specific checksums for the archive to be retrieved&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Then we set our source directory which must be correct for &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to find extracted files from the retrieved archive&lt;br /&gt;
&lt;br /&gt;
 REALPN = &amp;quot;mono-helloworld&amp;quot;&lt;br /&gt;
 S = &amp;quot;${WORKDIR}/${REALPN}-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now we override the compilation method to call &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; to build a particular .NET configuration against the a .SLN file in the archive&lt;br /&gt;
&lt;br /&gt;
 CONFIGURATION = &amp;quot;Debug&amp;quot;&lt;br /&gt;
 do_compile() {&lt;br /&gt;
         xbuild /p:Configuration=${CONFIGURATION} ${REALPN}_vs2010.sln&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Next we modify the installation method to make sure that the correct output files are installed and the executable scripts are modified to run the output assemblies&lt;br /&gt;
&lt;br /&gt;
 do_install() {&lt;br /&gt;
         mkdir -p ${D}${bindir}&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld&lt;br /&gt;
         mkdir -p ${D}${libdir}/helloworld/.debug  &lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.mdb ${D}${libdir}/helloworld/.debug&lt;br /&gt;
         install -m 0755 ${S}/bin/${CONFIGURATION}/*.exe ${D}${libdir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworld&lt;br /&gt;
         install -m 0755 ${S}/script.in ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@MONO@|mono|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@prefix@|/usr|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
         sed -i &amp;quot;s|@APP@|helloworld|g&amp;quot; ${D}${bindir}/helloworldform&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
Lastly we make sure that the .MDB debug files which are output are packaged correctly in the &amp;lt;code&amp;gt;-dbg&amp;lt;/code&amp;gt; package. The other assemblies in &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; will be packaged correctly in the main output package by default&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN}-dbg += &amp;quot;${libdir}/helloworld/.debug/*&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12802</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12802"/>
		<updated>2014-05-11T09:29:56Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an autotools recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive here]&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12801</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12801"/>
		<updated>2014-05-11T09:29:32Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an autotools recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [[https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive here]]&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12800</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12800"/>
		<updated>2014-05-11T09:29:11Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an autotools recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
  inherit autotools&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
                ${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [[https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive here]]&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12799</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12799"/>
		<updated>2014-05-11T09:22:54Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Breakdown of an autotools recipe */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
This is the contents of the mono-helloworld_1.1.bb recipe [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here]&lt;br /&gt;
&lt;br /&gt;
 require mono-helloworld.inc&lt;br /&gt;
&lt;br /&gt;
 SRC_URI[md5sum] = &amp;quot;79b0ba0044689789a54e3d55ec400fc0&amp;quot;&lt;br /&gt;
 SRC_URI[sha256sum] = &amp;quot;56388435f29ce94007155acc39593c900b6d3248a7f281e83ed2101a6da455f0&amp;quot;&lt;br /&gt;
&lt;br /&gt;
It can be seen that we provide a couple of checksums which relate to the release tarball that will be downloaded&lt;br /&gt;
&lt;br /&gt;
Similarly the is the included mono-helloworld.inc file can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here]&lt;br /&gt;
&lt;br /&gt;
  SUMMARY = &amp;quot;Mono Hello World&amp;quot;&lt;br /&gt;
  DESCRIPTION = &amp;quot;Test applications for Mono console and windows forms&amp;quot;&lt;br /&gt;
  AUTHOR = &amp;quot;Alex J Lennon &amp;lt;ajlennon@dynamicdevices.co.uk&amp;gt;&amp;quot;&lt;br /&gt;
  HOMEPAGE = &amp;quot;http://www.dynamicdevices.co.uk&amp;quot;&lt;br /&gt;
  SECTION = &amp;quot;mono/applications&amp;quot;&lt;br /&gt;
  PRIORITY = &amp;quot;optional&amp;quot;&lt;br /&gt;
  LICENSE = &amp;quot;GPLv3&amp;quot;&lt;br /&gt;
  LIC_FILES_CHKSUM = &amp;quot;file://LICENSE;md5=783b7e40cdfb4a1344d15b1f7081af66&amp;quot;&lt;br /&gt;
  DEPENDS = &amp;quot;mono&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/mono-helloworld/archive/v${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
  inherit autotools&lt;br /&gt;
&lt;br /&gt;
  FILES_${PN} = &amp;quot;${libdir}/helloworld/helloworld.exe \&lt;br /&gt;
  		${bindir}/helloworld \&lt;br /&gt;
         	${libdir}/helloworld/helloworldform.exe \&lt;br /&gt;
		${bindir}/helloworldform \&lt;br /&gt;
  &amp;quot;&lt;br /&gt;
&lt;br /&gt;
For more details on check-sums, licenses and so forth, see [[https://wiki.yoctoproject.org/wiki/Building_your_own_recipes_from_first_principles#Build_an_example_package_based_on_a_remote_source_archive here]]&lt;br /&gt;
&lt;br /&gt;
We have a dependency on the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package, and again we inherit the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; class to make use of the &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; functionality.&lt;br /&gt;
&lt;br /&gt;
Lastly we override &amp;lt;code&amp;gt;FILES_${PN}&amp;lt;/code&amp;gt; which controls the installed files which are added to the main output package. &amp;lt;code&amp;gt;${libdir}&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;${bindir}&amp;lt;/code&amp;gt; are standard GNU variable naming conventions for installation paths. For details see [http://www.gnu.org/prep/standards/html_node/Directory-Variables.html here] and [https://www.sourceware.org/autobook/autobook/autobook_106.html here].&lt;br /&gt;
&lt;br /&gt;
In this case we have made sure that the &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; executable goes to &amp;lt;code&amp;gt;/usr/lib/helloworld/helloworld.exe&amp;lt;/code&amp;gt; as does the &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
It might seem quite strange to be installing the executable assemblies to the &amp;lt;code&amp;gt;/usr/lib&amp;lt;/code&amp;gt; location, but this is in line with Mono application deployment recommendations [http://mono-project.com/Guidelines:Application_Deployment here].&lt;br /&gt;
&lt;br /&gt;
We then install wrapper scripts to &amp;lt;code&amp;gt;/usr/bin&amp;lt;/code&amp;gt; which can be called directly to run the respective examples. These scripts take the form&lt;br /&gt;
&lt;br /&gt;
  #!/bin/sh&lt;br /&gt;
  exec @MONO@ @prefix@/lib/helloworld/@APP@.exe $MONO_EXTRA_ARGS &amp;quot;$@&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12798</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12798"/>
		<updated>2014-05-11T09:05:29Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Testing the .NET executable on an emulated target */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12797</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12797"/>
		<updated>2014-05-11T09:05:09Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Build an image including Mono/.NET support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12796</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12796"/>
		<updated>2014-05-11T09:04:31Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with Mono for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
=== Install Mono ===&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworld&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12795</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12795"/>
		<updated>2014-05-10T12:52:12Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Adding the meta-mono layer to the Yocto build system|adding the meta-mono layer to the Yocto build system]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworldcode&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12794</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12794"/>
		<updated>2014-05-10T12:51:09Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image using the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworldcode&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12793</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12793"/>
		<updated>2014-05-10T12:39:44Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image with the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworldcode&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12792</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12792"/>
		<updated>2014-05-10T12:39:01Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[Work in progress]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image with the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworldcode&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono /usr/lib/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono /usr/lib/helloworld/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12791</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12791"/>
		<updated>2014-05-10T12:37:47Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[Work in progress]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image with the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworldcode&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono ??? helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono ??? helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=File:Monoemulatedhelloworldform.png&amp;diff=12790</id>
		<title>File:Monoemulatedhelloworldform.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=File:Monoemulatedhelloworldform.png&amp;diff=12790"/>
		<updated>2014-05-10T12:37:06Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Running monohelloworldform example within emulator&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Running monohelloworldform example within emulator&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=File:Monoemulatedhelloworld.png&amp;diff=12789</id>
		<title>File:Monoemulatedhelloworld.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=File:Monoemulatedhelloworld.png&amp;diff=12789"/>
		<updated>2014-05-10T12:36:43Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: Running helloworld example within qemu emulator&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Running helloworld example within qemu emulator&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12788</id>
		<title>Building and running embedded Linux .NET applications from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_and_running_embedded_Linux_.NET_applications_from_first_principles&amp;diff=12788"/>
		<updated>2014-05-10T12:36:19Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[Work in progress]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to including Mono in a build image with the meta-mono layer, then building and packaging an example .NET project for inclusion in that image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using Ubuntu 12.04 LTS as your host build system&lt;br /&gt;
* working with Yocto 1.6 (daisy) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/1.6/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Also install Mono on your host system as we&#039;ll use it to build and run some examples for test later&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
With Ubuntu 12.04 LTS this will install Mono version 2.10 which is now quite old (December 2011).&lt;br /&gt;
&lt;br /&gt;
If you wish to install a newer build of Mono to your host system you can follow the instructions [http://stackoverflow.com/questions/13365158/installing-mono-3-x-3-0-x-and-or-3-2-x here].&lt;br /&gt;
&lt;br /&gt;
  $ sudo add-apt-repository ppa:directhex/monoxide&lt;br /&gt;
  $ sudo apt-get update&lt;br /&gt;
  $ sudo apt-get install mono-complete&lt;br /&gt;
  $ mono --version&lt;br /&gt;
&lt;br /&gt;
This will install Mono 3.2.1 (August 2013)&lt;br /&gt;
&lt;br /&gt;
If you wish to use the absolute latest Mono then there are instructions you can follow to build a release tarball [http://www.mono-project.com/Compiling_Mono_From_Tarball here] and from git [http://mono-project.com/Compiling_Mono_From_GIT here]. Be aware this may not be straightforward and that there can be issues, such as with missing files, if you follow this process. &lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 1.6 release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (1.6) can be found [https://www.yoctoproject.org/download/yocto-project-16 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-1.6/poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-daisy-11.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 1.6 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
=== Building with autotools ===&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to compile non-.NET projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
Similarly it is possible to compile Mono/.NET projects using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/mono-helloworld here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworld.cs helloworld.cs] and [https://github.com/DynamicDevices/mono-helloworld/blob/master/src/helloworldform.cs  helloworldform.cs] you can see the first outputs a &#039;Hello World&#039; message to the console, and the second creates a Windows Form titled &#039;Hello World&#039;.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration for Mono is outside the scope of this guide, but the &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project is based on the &amp;lt;code&amp;gt;mono-skel&amp;lt;/code&amp;gt; example which can be found in the Autotools section of the Mono Application Deployment guidelines [http://mono-project.com/Guidelines:Application_Deployment here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds two .NET executables, &amp;lt;code&amp;gt;helloworldcode&amp;gt; and &amp;lt;code&amp;gt;helloworldform&amp;lt;/code&amp;gt; respectively, the first of which is a console application and the second of which is a simple Windows Forms application.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd mono-helloworld&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There are two new .NET executables &amp;lt;code&amp;gt;src/helloworld.exe&amp;lt;code&amp;gt; and &amp;lt;code&amp;gt;src/helloworldform.exe&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono src/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
=== Building with xbuild ===&lt;br /&gt;
&lt;br /&gt;
Many individuals develop with Visual Studio, Mono Develop, Xamarin Studio or other similar integrated development environments (IDEs).&lt;br /&gt;
&lt;br /&gt;
Mono provides &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt; which is the Mono implementation of Microsoft&#039;s &amp;lt;code&amp;gt;msbuild&amp;lt;/code&amp;gt;, discussed [http://mono-project.com/Microsoft.Build here].&lt;br /&gt;
&lt;br /&gt;
In essence this enables a developer to create a solution of projects within their IDE of choice, then use xbuild to build within the Mono environment.&lt;br /&gt;
&lt;br /&gt;
A useful workflow to follow may be to develop locally with an IDE of choice, commit to a git repository upon release, then use a Yocto recipe to build and package that release into an existing image, or for provision to a package feed for update to existing targets in the field.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; project discussed [[#Building with autotools|above]] also provides a solution and project files to support build with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;, or indeed with an IDE such as Visual Studio.&lt;br /&gt;
&lt;br /&gt;
If you have already built the examples using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; remove the folder and start again.&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ rm -Rf mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Check out the mono-helloworld project again&lt;br /&gt;
&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/mono-helloworld&lt;br /&gt;
&lt;br /&gt;
Run xbuild. (As you might guess from the name of the .sln file you could clone this example project to a Windows host and open it up with Visual Studio, and in fact that is how it was created)&lt;br /&gt;
&lt;br /&gt;
  $ xbuild /p:Configuration=Debug mono-helloworld_vs2010.sln&lt;br /&gt;
&lt;br /&gt;
This results in a number of new files, including two new Mono/.NET executables in &amp;lt;code&amp;gt;bin/Debug&amp;lt;/code&amp;gt; &amp;lt;code&amp;gt;helloworld.exe&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;helloworldform.exe &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworld.exe&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono bin/Debug/helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will give you a basic Windows Forms window title&lt;br /&gt;
&lt;br /&gt;
[[File:Monohelloworld.png|800px]]&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding the &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer to the Yocto build system ==&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method shown with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer contains Mono specific recipes to support execution of .NET applications on target boards. The layer can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the layer from its git repository and then add the layer to your &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; configuration by editing &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/meta-mono&lt;br /&gt;
  $ cd ~/yocto/poky-daisy-11.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-daisy-11.0.0/meta-mono \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.22.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;i686-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-12.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;1.6&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta&lt;br /&gt;
  meta-yocto&lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-mono         = &amp;quot;master:cb4998b3fbb7912468df8fc06d692fa872a21947&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an image including Mono/.NET support ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;meta-mono&amp;lt;/code&amp;gt; layer includes a recipe to build an image &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; based on the Yocto standard image &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To build this image&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-mono&lt;br /&gt;
&lt;br /&gt;
This may take a while, even if you have already built &amp;lt;code&amp;gt;core-image-minimal&amp;lt;code&amp;gt; as additional GUI support packages need to be built.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;core-image-mono&amp;lt;/code&amp;gt; recipe can be found [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.bb here] and pulls in an include file from [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/images/core-image-mono.inc here].&lt;br /&gt;
&lt;br /&gt;
You can see in the include file that extra packages are added to the standard &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; image.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot;libgdiplus mono mono-helloworld&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
This is how you would add Mono support to your image within a recipe, or within a .bbappend file. In fact it should only be necessary to add the &amp;lt;code&amp;gt;mono&amp;lt;/code&amp;gt; package as this has a dependency on &amp;lt;code&amp;gt;libgdiplus&amp;lt;/code&amp;gt; and it is not necessary to have the examples unless you wish to for testing purposes.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; recipe included here shows how to build the example project using &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt;. For details see the recipe itself [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld_1.1.bb here], and more importantly the include file it pulls in [http://git.yoctoproject.org/cgit/cgit.cgi/meta-mono/tree/recipes-mono/mono-helloworld/mono-helloworld.inc here].&lt;br /&gt;
&lt;br /&gt;
You could choose to replace &amp;lt;code&amp;gt;mono-helloworld&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;mono-helloworld-xbuild&amp;lt;/code&amp;gt; which as the name suggests shows how to build the eaxmple project with &amp;lt;code&amp;gt;xbuild&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Testing the .NET executable on an emulated target==&lt;br /&gt;
&lt;br /&gt;
Having built &amp;lt;code&amp;gt;core-image-mono&amp;lt;code&amp;gt; you can then run it up under &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
 $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and then a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
 $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Open up a terminal window using the appropriate icon, Log into the emulator as &#039;root&#039;, no password and run the examples.&lt;br /&gt;
&lt;br /&gt;
You can run the first with&lt;br /&gt;
&lt;br /&gt;
  $ mono helloworld.exe&lt;br /&gt;
&lt;br /&gt;
Or alternatively the recipe installs a script to wrap use of Mono, so you can use the form&lt;br /&gt;
&lt;br /&gt;
  $ helloworld&lt;br /&gt;
&lt;br /&gt;
This will output &lt;br /&gt;
&lt;br /&gt;
HelloWorld&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworld.png|400px]]&lt;br /&gt;
&lt;br /&gt;
You can run the second with&lt;br /&gt;
&lt;br /&gt;
  $ mono ??? helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ helloworldform&lt;br /&gt;
&lt;br /&gt;
Depending on your host environment (e.g. using SSH) you may need to explicitly set the &amp;lt;code&amp;gt;DISPLAY&amp;lt;/code&amp;gt; variable for this to work, with&lt;br /&gt;
&lt;br /&gt;
  $ export DISPLAY=:0&lt;br /&gt;
  $ mono ??? helloworldform.exe&lt;br /&gt;
&lt;br /&gt;
This will show a test Windows Forms form titled &#039;Hello World&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Monoemulatedhelloworldform.png|400px]]&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an autotools recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Breakdown of an xbuild recipe ==&lt;br /&gt;
&lt;br /&gt;
TBD&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Processes_and_Activities&amp;diff=12787</id>
		<title>Processes and Activities</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Processes_and_Activities&amp;diff=12787"/>
		<updated>2014-05-10T10:58:15Z</updated>

		<summary type="html">&lt;p&gt;Alex Lennon: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Welcome to the Processes and Activities Page!&lt;br /&gt;
&lt;br /&gt;
* [[Contribution Guidelines]]&lt;br /&gt;
* [[Recipe &amp;amp; Patch Style Guide]]&lt;br /&gt;
* [[Building your own recipes from first principles]]&lt;br /&gt;
* [[Distro Tracking]]&lt;br /&gt;
* [[Best Known Methods (BKMs) for Package Updating]]&lt;br /&gt;
* [[Working Behind a Network Proxy]]&lt;br /&gt;
* [[SDK Generator]]&lt;br /&gt;
* [[QA]]&lt;br /&gt;
* [[Kernel]]&lt;br /&gt;
* [[Core]]&lt;br /&gt;
* [[Bugzilla Configuration and Bug Tracking]]&lt;br /&gt;
* [[Bug Triage]]&lt;br /&gt;
* [[Yocto Point-Release Development Workflow]]&lt;br /&gt;
* [[Yocto Release Engineering]]&lt;br /&gt;
* [[Performance]]&lt;br /&gt;
* [[Security]]&lt;br /&gt;
* [[PAM Integration]]&lt;br /&gt;
* [[Program Management Plan]]&lt;br /&gt;
* [[Enable sstate cache]]&lt;br /&gt;
* [[Image Recipes]]&lt;br /&gt;
* [[Community Statistics]]&lt;br /&gt;
* Guidelines for contributing to meta-intel layer&lt;br /&gt;
* [[Building and running embedded Linux .NET applications from first principles]]&lt;/div&gt;</summary>
		<author><name>Alex Lennon</name></author>
	</entry>
</feed>