發布時間: 2018-05-16 19:45:09
[root@server0 maketest2]# cat foo.c addnum.c
#include<stdio.h>
extern int addnumbers(int a,int b);
int main()
{
int sum;
int x=5;
int y=8;
sum=addnumbers(x,y);
printf("sum of %d and %d is %d\n",x,y,sum);
return 0;
}
#include<stdio.h>
int addnumbers(int a,int b)
{
int sum;
sum=a+b;
return sum;
}
[root@server0 maketest2]# gcc -o foo foo.c addnum.c
[root@server0 maketest2]# ll
-rw-r--r--. 1 root root 83 Apr 12 03:06 addnum.c
-rwxr-xr-x. 1 root root 8579 Apr 12 03:14 foo
-rw-r--r--. 1 root root 177 Apr 12 03:13 foo.c
[root@server0 maketest2]# ./foo
sum of 5 and 8 is 13
[root@server0 maketest2]# cat Makefile
hello: foo.o addnum.o
gcc -o hello foo.o addnum.o
foo.o: foo.c
gcc -c foo.c
addnum.o: addnum.c
gcc -c addnum.c
clean:
rm -f *.o hello
[root@server0 maketest2]# make
gcc -c foo.c
gcc -c addnum.c
gcc -o hello foo.o addnum.o
[root@server0 maketest2]# ./hello
sum of 5 and 8 is 13
上一篇: {思科 CCNA-RS}EIGRP的簡介