Search by Tags

Build from Command-line


Your progress


In this section, you will build a simple hello-world using the previously configured Software Development Kit (SDK).

In this module you will:

  • Write a hello-world
  • Cross-compile from command-line
  • Deploy to the target through the network

Step 1

Create a file named hello-world.c with the following contents:

#include <stdio.h> int main(int argc, char *argv[]){ printf("Hello world!\n"); return 0; }

Step 2

Cross-compile the code. Make sure that you exported the required variables in the last how-to section.

Note: The Toradex SDK must be installed in the system and the correct variables exported. If you have any doubts, please go back to the last how-to section "Configure Toolchain".

Warning: If you open a new terminal window, you must export the variables again. To check if a variable is set, use the echo command, for instance: "echo ${CC}".

${CC} -Wall hello-world.c -o hello-world

Step 3

Log in to the board using picocom. Find the target IP address. Search for the inet addr from the eth0 interface:

root@apalis-imx6:~# ifconfig 
eth0      Link encap:Ethernet  HWaddr 00:14:2D:49:E8:8E  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::214:2dff:fe49:e88e/64 Scope:Link
          inet6 addr: 2804:14d:ac82:116c:214:2dff:fe49:e88e/64 Scope:Global
          RX packets:699 errors:0 dropped:0 overruns:0 frame:0
          TX packets:562 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:86400 (84.3 KiB)  TX bytes:56325 (55.0 KiB)
lo        Link encap:Local Loopback  
          inet addr:  Mask:
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:330 errors:0 dropped:0 overruns:0 frame:0
          TX packets:330 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:30218 (29.5 KiB)  TX bytes:30218 (29.5 KiB)
usb0      Link encap:Ethernet  HWaddr 00:14:2D:FF:FF:FF  
          inet addr:  Bcast:  Mask:
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

In this example, the target IP address is

Step 4

Back to the host computer, copy the application to the target using SCP. You may be prompted to continue during the first connection. If this is the case, just type yes and press Enter:

user@host:~$ scp hello-world root@
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:+N5WCsnEtQXEnYWyMXxswZLf4hEVgmHPOR2pZgJRdrg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '' (ECDSA) to the list of known hosts.

Step 5

In the target terminal, run the application:

root@apalis-imx6:~# ./hello-world 
Hello world!