天嵌 ARM开发社区

 找回密码
 注册
查看: 2791|回复: 13

简单的建立一个交叉编译环境和移植helloworld程序

[复制链接]
qiqiu_007_003 发表于 2010-10-20 09:38:33 | 显示全部楼层 |阅读模式
这个比较简单,但是对于新手刚刚入门应该还算可以吧。
拷贝arm-linux-gcc-3.4.1.tar.bz2至根目录/。
进入根目录,执行解包:
[root@localhost root]# cd /
[root@localhost /]#tar xjvf arm-linux-gcc-3.4.1.tar.bz2

设置系统环境变量:
[root@localhost arm]#export PATH=$PATH:/usr/local/arm/3.4.13.4.1/bin
这样,内核或其他应用程序均可以用arm-linux-来指定使用该交叉编译器。

自行编写一个程序测试:
示例helloworld.c:

#include <stdio.h>
int main(void)
{
        printf("hello world\n");
        return 0;
}

然后在命令行执行:
$arm-linux-gcc helloworld.c -o helloworld
$file helloworld

如果输出以下信息,说明编译成功。
helloworld: ELF 32-bit LSB executeable, ARM, version 1, dynamically linked (uses shared libs), not stripped

编译成功后或者用ZM协议或者用nfs将文件扔到开发板中,
运行:
./helloworld
移植成功~~~~
天嵌_support1 发表于 2010-10-20 09:57:27 | 显示全部楼层
1# qiqiu_007_003


呵呵呵,继续加油!
frisen 发表于 2010-12-15 14:40:52 | 显示全部楼层
还不错的,重要的是原理,学习了。
BIGTOM 发表于 2010-12-23 01:11:22 | 显示全部楼层
为什么我./hello就不行呢
天嵌_support1 发表于 2010-12-23 11:02:19 | 显示全部楼层
4# BIGTOM


不行总有个错误提示的
BIGTOM 发表于 2010-12-23 12:45:44 | 显示全部楼层
./Hello后显示: -/bin/sh: ./Hello: not found
天嵌_support1 发表于 2010-12-23 14:40:56 | 显示全部楼层
6# BIGTOM


引起这个问题有俩吧:
1.你的编译器不是4.3.3
2.你传输二进制文件到板子时,该文件没有以二进制方式传输,坏掉了
sunnyxq 发表于 2011-3-31 11:03:59 | 显示全部楼层
能具体说下怎么用ZM协议或者nfs将文件扔到开发板中吗,我是新手,这方面很迷茫。谢谢
苹果 发表于 2011-4-13 08:58:39 | 显示全部楼层
如果可以和版主聊一聊就好了
我现在在移植那个helloworld。ko到板子上面去,不知道为什么要和文件系统挂钩
liangpan 发表于 2011-4-13 09:01:29 | 显示全部楼层
8# sunnyxq
如果是从NFS文件系统启动 只需要将文件拷贝到文件系统目录中就可以了。
津津 发表于 2011-4-25 16:03:47 | 显示全部楼层
嗯,学习了。这个方法我才学会
zxw54007 发表于 2011-8-24 15:28:55 | 显示全部楼层
学习了,试试去
dadongwusheng 发表于 2012-4-28 18:38:01 | 显示全部楼层
我的也不能运行啊,错误原因是
[root@EmbedSky sky]# ./hello-c
Segmentation fault
会飞的小猪 发表于 2013-12-12 13:14:35 | 显示全部楼层
求宿主机配置,你在什么环境下运行arm-linux-gcc的,虚拟机?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

i.MX8系列ARM cortex A53 M4 工控板上一条 /1 下一条

Archiver|手机版|小黑屋|天嵌 嵌入式开发社区 ( 粤ICP备11094220号-2 )

GMT+8, 2024-10-5 18:34 , Processed in 1.038019 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表