Difference between revisions of "IoTGateway/BSP/Linux/AM335x/C/C++ Development"
From ESS-WIKI
(→Development of C/C++ Programs) |
|||
Line 3: | Line 3: | ||
= Development of C/C++ Programs = | = 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”: | ||
+ | <pre> | ||
+ | $ sudo su | ||
+ | </pre> | ||
+ | Type user password. | ||
+ | * Create the develop environment using flowing command: | ||
+ | <pre> | ||
+ | # source /usr/local/cross_compiler/linux-devkit/environment-setup | ||
+ | # cd /root/AM57XX_LBBxxxx_yyyy_mm_dd/source | ||
+ | # mkdir helloworld | ||
+ | # cd helloworld | ||
+ | # gedit hellowrold.c | ||
+ | </pre> | ||
+ | |||
+ | * Edit the helloworld.c with the following source code: | ||
+ | <pre> | ||
+ | #include <stdio.h> | ||
+ | void main() | ||
+ | { | ||
+ | printf("Hello World!\n"); | ||
+ | } | ||
+ | </pre> | ||
+ | Save the file and exit. | ||
+ | |||
+ | * Compile helloworld.c using flowing command: | ||
+ | <pre> | ||
+ | # $CC -o helloworld helloworld.c | ||
+ | </pre> | ||
+ | Then you can see “helloworld” in current directory. | ||
+ | * Run the executable file helloworld on the your target board(such as RSB-4220). | ||
+ | Insert the Linux system SD card to your developing computer. | ||
+ | <pre> | ||
+ | # cp helloworld /media/rootfs/tool | ||
+ | </pre> | ||
+ | Remove this SD card and insert it to your target board, then open serial console. | ||
+ | On your target platform, type: | ||
+ | <pre> | ||
+ | # root (Login) | ||
+ | # cd /tool | ||
+ | # ./helloworld | ||
+ | Hello World! | ||
+ | </pre> | ||
+ | Now you should be able to see “Hello World!” shown on console. |
Revision as of 08:45, 28 September 2016
Contents
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 “helloworld” in current directory.
- 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.