sama5d3 xplained 开发板运行主机编写的HelloWorld

[成功方案]
第一步:使用交叉工具链 Sourcery G++ Lite 2009q3-67
这里有需要的同学可能从这里下载

第二步:编写hello.c
#include <stdio.h>

int main() {
    printf("hello, world!");

    return 0;
}

第三步:交叉编译
$ arm-none-linux-gnueabi-gcc hello.c -o hello -static

 

第四步:开发板将编译好的程序下载并执行
root@sama5d3_xplained:~/test# tftp -g -l hello 192.168.1.25
root@sama5d3_xplained:~/test# chmod 777 hello
root@sama5d3_xplained:~/test# ./hello                               
hello, world!

[再回首]
一、第一步使用的是 Sourcery G++ Lite 2011.03-42
编译
$ /opt/arm-cross/arm-2011.03/bin/arm-none-eabi-gcc hello.c -o hello

 

一直提示如下信息 (更换交叉工具链后问题不再出现)
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 00008018
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text+0x18): undefined reference to `_sbrk'
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text+0x20): undefined reference to `_write'
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text+0x18): undefined reference to `_close'
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text+0x1c): undefined reference to `_fstat'
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text+0x18): undefined reference to `_isatty'
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text+0x20): undefined reference to `_lseek'
/opt/arm-cross/arm-2011.03/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text+0x20): undefined reference to `_read'
collect2: ld returned 1 exit status

 

二、第三步中没有加 -static
开发板上执行之后提示如下信息(加-static后问题解决)
root@sama5d3_xplained:~/test# ./hello                                        
sh: ./hello: No such file or directory
posted @ 2015-02-15 14:57  阿青1987  阅读(449)  评论(0编辑  收藏  举报