Moxa IA261-I-T-LX [17/71] Compiling hello c

Moxa IA261-I-T-LX [17/71] Compiling hello c
IA260-261-262 EM-2260 LX User’s Manual Getting Started
2-9
Compiling Hello.c
The package CD contains several example programs. Here we use hello.c as an example to show
you how to compile and run your applications. Type the following commands from your PC to
copy the files used for this example from the CD to your computer’s hard drive:
# cd /tmp/
# mkdir example
# cp –r /mnt/cdrom/example/* /tmp/example
To compile the program, go to the hello subdirectory and issue the following commands:
#cd example/hello
#make
You should receive the following response:
[root@localhost hello]# make
/usr/local/arm-linux/bin/arm-linux-gcc –o hello-release hello.c
/usr/local/arm-linux/bin/arm-linux-strip –s hello-release
/usr/local/arm-linux/bin/arm-linux-gcc –ggdb -o hello-debug hello.c
[root@localhost hello]# _
Both hello-release and hello-debug will be generated, which are described below:
hello-release—an ARM platform execution file (created specifically to run on the
IA260/IA261/IA262/EM-2260)
hello-debug—an ARM platform GDB debug server execution file (see Chapter 5 for details about
the GDB debug tool)
NOTE Since Moxa’s tool chain places a specially designed Makefile in the directory
/tmp/example/hello, be sure to type the #make command from within that directory. This
special Makefile uses the arm-linux-gcc compiler to compile the hello.c source code for the
ARM environment. If you type the #make command from within any other directory, Linux will
use the x86 compiler (for example, cc or gcc).
Uploading and Running the “Hello” Program
Use the following commands to upload hello-release to the IA260/IA261/IA262/EM-2260 via
FTP.
1. From the PC, type:
#ftp 192.168.3.127
2. Use the bin command to set the transfer mode to Binary mode, and then use the put command
to initiate the file transfer:
ftp> bin
ftp> put hello-release
3. From the IA260/IA261/IA262/EM-2260, type:
# chmod +x hello-release
# ./hello-release
The word Hello will be printed on the screen.
root@Moxa:~# ./hello-release
Hello

Содержание

Похожие устройства

Скачать