Jetson/Hello World

< Jetson
Revision as of 08:15, 2 July 2014 by Shervin.emami (talk | contribs) (Wrote a simple Hello World native development tutorial)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Introduction to application development for Jetson TK1

Jetson TK1 comes pre-installed with Linux4Tegra (L4T) that is based on the popular Ubuntu 14.04 Linux desktop. So can write software on Jetson TK1 using the same ways you would write software on a desktop. Unlike Android or iOS development that require tedious build systems, you can simply use various popular Linux development tools such as Emacs/Vim, Eclipse, KDevelop, QtCreator, Gedit, Geany, NetBeans, Code::Blocks, Komodo Edit, Bluefish, etc.

Jetson TK1 is using an ARM based CPU, whereas most desktops are using Intel x86 based CPUs, so there are actually 2 options for developing Jetson TK1 code:

  • Native development (ie: compiling ARM code directly on Jetson TK1)
  • Cross-development (ie: cross-compiling ARM code on an x86 PC and copying it onto the Jetson TK1)

Native development typically takes longer to compile your code than cross-development does, but it is much easier to setup native development, so it is recommended to do native development in most cases for Jetson TK1. For slower ARM CPUs such as in Raspberry Pi, native compilation takes much much longer than cross-compilation on a desktop, but on a fast ARM CPU such as in Jetson TK1, the speed isn't too much slower than a desktop CPU.

Natively compiling a Hello World application on Jetson TK1

  • It is assumed you are logged into your Jetson TK1 device, such as by following one of the 2 methods listed in Basic steps to access the board and access internet.
  • Open a new C/C++ file in your Jetson TK1 home folder (/home/ubuntu). If you are using the graphical desktop then open a GUI editor such as Gedit or any Linux IDE you like, or if you are using a text-only console then you can run "nano helloworld.cpp" (or "vi helloworld.cpp" if you are experienced with Vi/Vim).
  • Paste the following contents into the file and save it:
// Simple Hello World application. For Jetson TK1.
#include <iostream> 

using namespace std;
int main()
    cout << "Hello world!" << endl;
    return 0;
  • Now compile & link your program natively, such as by clicking "Build" in your IDE or opening "terminal" in Ubuntu and running this in the terminal:
g++ helloworld.cpp -o helloworld
  • Assuming it didn't have any errors, now you can run it, such as by entering this in your terminal:
  • It should show "Hello world!" printed to your terminal!