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

转载于:https://www.cnblogs.com/aqing1987/p/4292923.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值