手动gcc编译多个文件 和利用makefile 编译多个文件的区别


手动 gcc 编译多个文件 和利用 makefile 编译多个文件的区别
[root@localhost ~]# cd /export
[root@localhost export]# ls
a.out  hello  hello.c  hello.o  main.tgz  thanks.c
[root@localhost export]# tar -zxfv main.tgz
tar (child): v: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
[root@localhost export]# ls
a.out  hello  hello.c  hello.o  main.tgz  thanks.c
[root@localhost export]# tar -zxvf main.tgz
cos_value.c
haha.c
main.c
sin_value.c
[root@localhost export]# ls
a.out        haha.c  hello.c  main.c    sin_value.c
cos_value.c  hello   hello.o  main.tgz  thanks.c
[root@localhost export]# cat main.c
#include <stdio.h>
#define pi 3.14159
char name[15];
float angle;

int main(void)
{
        printf ("\n\nPlease input your name: ");
        scanf  ("%s", &name );
        printf ("\nPlease enter the degree angle (ex> 90): " );
        scanf  ("%f", &angle );
        haha( name );
        sin_value( angle );
        cos_value( angle );
}
[root@localhost export]# cat haha.c
#include <stdio.h>
int haha(char name[15])
{
        printf ("\n\nHi, Dear %s, nice to meet you.", name);
}
[root@localhost export]# ls
a.out        haha.c  hello.c  main.c    sin_value.c
cos_value.c  hello   hello.o  main.tgz  thanks.c
[root@localhost export]# cat sin_value.c
#include <stdio.h>
#include <math.h>
#define pi 3.14159
float angle;

void sin_value(void)
{
        float value;
        value = sin ( angle / 180. * pi );
        printf ("\nThe Sin is: %5.2f\n",value);
}
[root@localhost export]# cat cos_value.c
#include <stdio.h>
#include <math.h>
#define pi 3.14159
float angle;

void cos_value(void)
{
        float value;
        value = cos ( angle / 180. * pi );
        printf ("The Cos is: %5.2f\n",value);
}

手动编译成目标文件
[root@localhost export]# gcc -c main.c
[root@localhost export]# ls
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值