Moxa UC-8410A-T-LX [67/86] Bcross compiling applications and libraries

Moxa UC-8410A-T-LX [67/86] Bcross compiling applications and libraries
UC-8410A Series Linux Software Programmer’s Guide
6-5
Obtaining Help
You can use the Linux man utility to get help on many of the utilities provided by the tool chain located at
/usr/local/arm-linux-gnueabihf-4.7-20130415/share/doc/gcc-linaro-arm-linux-gnueabihf/man/. For example,
to get help on the arm-linux-gnueabihf-gcc compiler, issue the command:
moxa@Moxa:~$ man
/usr/local/arm-linux-gnueabihf-4.7-20130415/share/doc/gcc-linaro-arm-linux-gnueab
ihf/man/man1/arm-linux-gnueabihf-gcc.1
Cross Compiling Applications and Libraries
To compile a simple C application, use the cross compiler instead of the regular compiler:
#arm-linux-gnueabihf-gcc –o example –Wall –g –O2 example.c
#arm-linux-gnueabihf-strip –s example
#arm-linux-gnueabihf-gcc -ggdb –o example-debug example.c
Test ProgramDeveloping Hello.c
In this section, we use the standard “Hello” programming example to illustrate how to develop a program for
the UC-8410A-LX.
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}
The following compiler tools are provided:
ar Manage archives (static libraries)
as Assembler
c++, g++ C++ compiler
cpp C preprocessor
gcc C compiler
gdb Debugger
ld Linker
nm Lists symbols from object files
objcopy Copies and translates object files
objdump Displays information about object files
ranlib Generates indexes to archives (static libraries)
readelf Displays information about ELF files
size Lists object file section sizes
strings Prints strings of printable characters from files (usually object files)
strip Removes symbols and sections from object files (usually debugging information)
Compiling Hello.c with Native Compilation
Follow these steps for native compilation.
apt-get install build-essential
sudo gcc –o hello-release hello.c
sudo strip –s hello-release

Содержание

Скачать