背景

近期工作,需要部署嵌入式设备中。对于嵌入式的学习,进行一些记录。

本机操作

1 .保存一个hello.c文件

#include <stdio.h>
int main(int argc,char const *argv[])
{
   printf("hello arm\n");
   return 0;
}

2.交叉编译(本机用的交叉编译器为:arm-linux-gnueabihf-gcc )

arm-linux-gnueabihf-gcc hello.c -static -o hello_arm

这里选择-static静态链接编译,动态链接编译需要很多库,不方便。
这里会生成hello_arm可执行文件(在arm架构的开发板上可执行)
这里可以查看该文件类型:
命令

file hello_arm

结果:
hello_arm: ELF 32-bit LSB executable, ARM, EABI5 version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=0c48010148442cb1f9a651e0695e717866416039, with debug_info, not stripped

ARM开发板上操作

将hello_arm文件传到开发板上(这里是VIM3 Amlogic板子,上传方式本次用U盘挂载的方式)
切换到该文件所在目录。
执行:

./hello_arm

结果输出:
hello arm

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐