arm-linux交叉编译范例1

环境

vscode

gcc

arm-gcc

范例

桌面新建文件夹

vscode打开文件夹

新建一个hello.c文件

源码写入

#include <stdio.h>

int main(int argc,char * argv[])
{
    printf("hello!!!");
    return 0;

}

编译linux下运行

gcc -o helloc hello.c

编译arm-linux下运行

arm-linux-gcc -o hellob hello.c

编译armv7--linux下运行(我工程机使用的AM3352BZCZ)

arm-linux-gnueabihf-gcc -o helloarm hello.c

linux下直接运行

./helloc

把生成的helloarm文件下载到armv7-linux中【先共享或ftp复制到windwos,再用xftp用ftp下载到arm中】

使用xshell的telnet方式23端口登陆

修改权限(使可执行)

chmod +x helloarm

armv7-linux下运行

命令./helloarm

完成OK

root@am335x:/chenhao# chmod +x helloarm 
root@am335x:/chenhao# ./helloarm 
hello!!!root@am335x:/chenhao# 

发布了331 篇原创文章 · 获赞 140 · 访问量 71万+

猜你喜欢

转载自blog.csdn.net/chenhao0568/article/details/99689941