C/C++ Development

From ESS-WIKI
Revision as of 08:48, 28 September 2016 by Zhengguang.yang (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Development of C/C++ Programs

This section will guide you how to write a sample application “Hello World”. You can refer to following steps:

  • Open "Terminal" on Ubuntu host PC, and Change to “root”:
$ sudo su

Type user password.

  • Create the develop environment using flowing command:
# source /usr/local/cross_compiler/linux-devkit/environment-setup
# cd /root/AM57XX_LBBxxxx_yyyy_mm_dd/source
# mkdir helloworld
# cd helloworld
# gedit hellowrold.c
  • Edit the helloworld.c with the following source code:
#include <stdio.h>
void main()
{
  printf("Hello World!\n");
}

Save the file and exit.

  • Compile helloworld.c using flowing command:
# $CC -o helloworld helloworld.c

Then you can see a binary file named “helloworld” in current directory if no error.

  • Run the executable file helloworld on the your target board(such as RSB-4220).

Insert the Linux system SD card to your developing computer.

# cp helloworld /media/rootfs/tool

Remove this SD card and insert it to your target board, then open serial console. On your target platform, type:

# root (Login)
# cd /tool
# ./helloworld 
Hello World!

Now you should be able to see “Hello World!” shown on console.