<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.somlabs.com/index.php?action=history&amp;feed=atom&amp;title=Building_simple_C_program</id>
	<title>Building simple C program - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.somlabs.com/index.php?action=history&amp;feed=atom&amp;title=Building_simple_C_program"/>
	<link rel="alternate" type="text/html" href="https://wiki.somlabs.com/index.php?title=Building_simple_C_program&amp;action=history"/>
	<updated>2026-04-28T05:05:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://wiki.somlabs.com/index.php?title=Building_simple_C_program&amp;diff=1728&amp;oldid=prev</id>
		<title>KrzysztofChojnowski at 13:27, 31 January 2020</title>
		<link rel="alternate" type="text/html" href="https://wiki.somlabs.com/index.php?title=Building_simple_C_program&amp;diff=1728&amp;oldid=prev"/>
		<updated>2020-01-31T13:27:22Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 13:27, 31 January 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;PageHeaderBuilding &lt;/del&gt;simple C program}} __toc__&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;PageHeader|Building &lt;/ins&gt;simple C program}} __toc__&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== On target system ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== On target system ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>KrzysztofChojnowski</name></author>
	</entry>
	<entry>
		<id>https://wiki.somlabs.com/index.php?title=Building_simple_C_program&amp;diff=1617&amp;oldid=prev</id>
		<title>KrzysztofChojnowski: Created page with &quot;{{PageHeaderBuilding simple C program}} __toc__  == On target system ==  One of few ways to create applications is to connect to target board via UART-USB converter or SSH cli...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.somlabs.com/index.php?title=Building_simple_C_program&amp;diff=1617&amp;oldid=prev"/>
		<updated>2019-11-06T12:00:46Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{PageHeaderBuilding simple C program}} __toc__  == On target system ==  One of few ways to create applications is to connect to target board via UART-USB converter or SSH cli...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{PageHeaderBuilding simple C program}} __toc__&lt;br /&gt;
&lt;br /&gt;
== On target system ==&lt;br /&gt;
&lt;br /&gt;
One of few ways to create applications is to connect to target board via UART-USB converter or SSH client, use a text editor (for example nano) to write code and compile them with gcc. To do that install compiler and some additional software:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@somlabs:~# apt install build-essential&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now create your program file with nano editor:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@somlabs:~# nano HelloWorld.c&amp;lt;/pre&amp;gt;&lt;br /&gt;
Enter the code below to the file:&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
		printf(&amp;quot;Hello world!\n&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file (Ctrl+O) and exit (Ctrl+X). Now you can compile and run your program:&lt;br /&gt;
&amp;lt;pre&amp;gt;root@somlabs:~# gcc -o HelloWorld HelloWorld.c&lt;br /&gt;
root@somlabs:~# ./HelloWorld&lt;br /&gt;
Hello world!&lt;br /&gt;
root@somlabs:~#&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== On Linux host ==&lt;br /&gt;
Other method is to write your application on host system. In this case Ubuntu 18.04 will be used with the Linaro toolchain.&lt;br /&gt;
&lt;br /&gt;
Download and extract the toolchain:&lt;br /&gt;
&amp;lt;pre&amp;gt;wget https://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/arm-linux-gnueabihf/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz&lt;br /&gt;
tar -xf gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf.tar.xz&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Export the path to the compiler:&lt;br /&gt;
&amp;lt;pre&amp;gt;export PATH=$PATH:&amp;lt;KERNEL_PATCH_PATH&amp;gt;/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you are ready to create basic application on your host, first steps are just like in case of development on target, but you need to perform them on your host:&lt;br /&gt;
Create your program file with nano editor:&lt;br /&gt;
&amp;lt;pre&amp;gt;nano HelloWorld.c&amp;lt;/pre&amp;gt;&lt;br /&gt;
Enter the code below to the file:&lt;br /&gt;
&amp;lt;pre&amp;gt;#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
int main() {&lt;br /&gt;
		printf(&amp;quot;Hello world!\n&amp;quot;);&lt;br /&gt;
		return 0;&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file (Ctrl+O) and exit (Ctrl+X). Now you can compile and run your program:&lt;br /&gt;
&amp;lt;pre&amp;gt;arm-linux-gnueabihf-gcc -o HelloWorld HelloWorld.c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The created executable can be run only on ARM architecture - it can be verified by calling the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;file HelloWorld&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The output contains the details about the binary:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;HelloWorld: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-, for GNU/Linux 3.2.0, BuildID[sha1]=f34ae20591d1c22fdcfcaa8f6aee9568f9b250e4, with debug_info, not stripped&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now it is time to upload executable file to the target (you need to find it&amp;#039;s IP before, for example by running ip a command on target and allow access to the target using ssh protocol):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;scp HelloWorld root@192.168.0.53:/root&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your executable should be in /root directory of the target system, you can run it (enter the command below on target):&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;pre&amp;gt;root@somlabs:~# ./HelloWorld&lt;br /&gt;
Hello world!&lt;br /&gt;
root@somlabs:~#&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>KrzysztofChojnowski</name></author>
	</entry>
</feed>