arm-linux下 编写Makefile

c代码 a.c如下

int main(int argc ,char **argv)
{
        printf("hello world!/n");
        return 0;
}

方法1
Makefile 内容如下

CROSS=/usr/local/arm/3.4.1/bin/arm-linux-
CC=gcc

all:
 $(CROSS)$(CC) -o test a.c

保存后
[root@5linux src]# make
/usr/local/arm/3.4.1/bin/arm-linux-gcc -o test a.c
查看生成的文件
[root@5linux src]# ls
a.c  Makefile  test
砍下文件属性
[root@5linux src]# file test
test: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped

方法2 带参数
Makefile 内容如下
CROSS=
CC=gcc

all:
 $(CROSS)$(CC) -o test a.c

保存

生成当前系统程序
[root@5linux src]# make
gcc -o test a.c
a.c: In function ‘main’:
a.c:3: 警告:隐式声明与内建函数 ‘printf’ 不兼容
查看文件属性
[root@5linux src]# file test
test: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.9, dynamically linked (uses shared libs), for GNU/Linux 2.6.9, not stripped
生存arm 下的程序
[root@5linux src]# make CROSS=/usr/local/arm/3.4.1/bin/arm-linux-
/usr/local/arm/3.4.1/bin/arm-linux-gcc -o test a.c
查看文件属性
[root@5linux src]# file test
test: ELF 32-bit LSB executable, ARM, version 1 (ARM), for GNU/Linux 2.4.3, dynamically linked (uses shared libs), for GNU/Linux 2.4.3, not stripped

 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值