(1)ARM40-A5板应用程序——hello world

(1)ARM40-A5板应用程序——hello world

2017.03.19

一、源码

    在ubuntu上 touch hello.c 建立hello.c文件,输入代码如下:

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

二、编译

在ubuntu上输入命令编译 hello.c 文件:

gcc -o hello hello.c

在ubuntu上执行程序:

./hello

得到输出:

hello, world!

三、交叉编译

在ubuntu上输入命令编译 hello.c 文件:

        arm-none-linux-gnueabi-gcc hello.c -o hello -static

    得到 hello 文件,将该文件拷贝到ARM40-A5板中,在ARM40-A5板上执行程序:

./hello

得到输出:

hello, world!

四、问题点

    (1)第(二)步在ubuntu上调试的主要目的: 

            ① 在 ubuntu 上先编译调试一遍,可以排除错误。

            ② 只有最后需要到ARM40-A5上验证的时候,才需要拷贝到ARM40-A5板上执行程序。

    (2)arm-none-linux-gnueabi-gcc 编译器的安装方法见参考文章《ARM40-A5 GCC交叉编译环境搭建》。

    (3)把文件从ubuntu拷贝到ARM40-A5板的方法见本blog的文章《把文件从ubuntu拷贝到ARM40-A5板的方法》。

参考文章:

http://www.cnblogs.com/aqing1987/p/4292923.html

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

ARM40-A5 GCC交叉编译环境搭建

https://blog.csdn.net/jzzy_hony/article/details/80859450

猜你喜欢

转载自blog.csdn.net/vonchn/article/details/63684107