交叉编译helloworld

1、源文件:
[franky@franky ~]$ cat hello.c
#include <stdio.h>
#include <stdlib.h>
int main()
{
        printf("hello world/n");
        exit(0);
}
2、在RHEL5下编译:
[franky@franky ~]$ gcc -o helloworld -c hello.c -elf2flat
3、下载到板子上:
root:/home> wget ftp://franky:xxxxxxxxx@10.0.0.xxx/helloworld
Connecting to 10.0.0.xxx [10.0.0.xxx:21]
helloworld           100% |*****************************|   900    --:--:-- ETA
4、运行出错:
root:/home> chmod +x helloworld
root:/home> ./helloworld
 ELF: not found
5、原因:编译器使用错误
Makefile内的配置参数为:
FDPIC_CC = bfin-linux-uclibc-gcc
FLAT_CC = bfin-uclinux-gcc
6、重新编译:
[franky@franky ~]$ bfin-linux-uclibc-gcc -o helloworld -c hello.c -elf2flat
7、下载并运行: (出错)
root:/home> ./helloworld
./helloworld: cannot execute
8、出错原因:编译器依然使用错误,flat模式下需要用bfin-uclinux-gcc, 且要打开-Wl, -elf2flt 选项。
9、重新编译:
[franky@franky ~]$ bfin-uclinux-gcc -Wl, -elf2flt hello.c -o newhello
10、下载、运行:
root:/home> ./newhello
hello world   (出现正确结果,问题解决)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值