[成功方案]
第一步:使用交叉工具链 Sourcery G++ Lite 2009q3-67
这里有需要的同学可能从这里下载
第二步:编写hello.c
第三步:交叉编译
第四步:开发板将编译好的程序下载并执行
hello, world!
[再回首]
一、第一步使用的是 Sourcery G++ Lite 2011.03-42
编译
一直提示如下信息 (更换交叉工具链后问题不再出现)
二、第三步中没有加 -static
开发板上执行之后提示如下信息(加-static后问题解决)
root@sama5d3_xplained:~/test# ./hello
sh: ./hello: No such file or directory
第一步:使用交叉工具链 Sourcery G++ Lite 2009q3-67
这里有需要的同学可能从这里下载
- 链接:http://pan.baidu.com/s/1bn8f3if
- 密码:wp0z
第二步:编写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
[再回首]
一、第一步使用的是 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后问题解决)
root@sama5d3_xplained:~/test# ./hello
sh: ./hello: No such file or directory