编译 Hello World

步骤1 在开发环境上,使用tar命令对SDK.tar.gz安装包进行解压(如下示例将SDK解压到了/
home/test/目录下,您可根据需要自行指定解压目录)。


tar -zxvf SDK.tar.gz -C /home/test


步骤2 使用source命令执行aos目录下envset.sh脚本,配置aos场景下的编译工具链所在路
径。


source /home/test/SDK/aos/envset.sh


步骤3 检查LLVM编译工具链配置是否正确。


which clang


输出结果: /home/test/SDK/aos/bin/clang


步骤4 准备代码,此处示例代码如下:


ubuntu:/home/test/SDK/helloworld$ vim helloworld.c

文件中的内容,是输出一句hello world
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}


步骤5 准备Makefile,示例如下:


src_file=helloworld.c
elf_file=helloworld
all:
${CC} -I ${SYSROOT}/usr/include -L ${SYSROOT}/usr/lib64 ${src_file} -o ${elf_file}


步骤6 执行make命令,编译Hello World


ubuntu:/home/test/SDK/helloworld$ export SYSROOT=/home/test/SDK/aos/sysroot/
ubuntu:/home/test/SDK/helloworld$ make


步骤7 查询编译结果,其中hellworld为编译后的可执行文件


ubuntu: /home/test/SDK/helloworld$ ls


helloworld.c helloworld Makefile


----结束
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值