::::::::::::::
add.c
::::::::::::::
int add( int a, int b)
{
return a+b;
}
::::::::::::::
csmath.h
::::::::::::::
#ifndef _CSMATH_
#define _CSMATH_
int add(int a, int b);
int sub(int a, int b);
#endif
::::::::::::::
makefile
::::::::::::::
tt: add.o test.o sub.o
gcc -o tt test.o add.o
test.o:
gcc -c test.c
add.o:
gcc -c add.c
sub.o:
gcc -c sub.c
clean:
rm -rf *.o
rm -rf tt
::::::::::::::
makefile.bk
::::::::::::::
tt: add.o sub.o test.o
gcc -o tt test.o add.o
test.o: test.c add.o sub.o
gcc -c test.c
add.o:
gcc -c add.c
sub.o: sub.c
gcc -c sub.c
clean:
rm -rf *.o
rm -rf tt
::::::::::::::
sub.c
::::::::::::::
#include "csmath.h"
int sub( int a, int b)
{
return a-b;
}
::::::::::::::
test.c
::::::::::::::
#include <stdio.h>
#include "csmath.h"
int main()
{
printf("Hello,world!\n");
printf("add result: %d",add(1,3));
return 0;
}
add.c
::::::::::::::
int add( int a, int b)
{
return a+b;
}
::::::::::::::
csmath.h
::::::::::::::
#ifndef _CSMATH_
#define _CSMATH_
int add(int a, int b);
int sub(int a, int b);
#endif
::::::::::::::
makefile
::::::::::::::
tt: add.o test.o sub.o
gcc -o tt test.o add.o
test.o:
gcc -c test.c
add.o:
gcc -c add.c
sub.o:
gcc -c sub.c
clean:
rm -rf *.o
rm -rf tt
::::::::::::::
makefile.bk
::::::::::::::
tt: add.o sub.o test.o
gcc -o tt test.o add.o
test.o: test.c add.o sub.o
gcc -c test.c
add.o:
gcc -c add.c
sub.o: sub.c
gcc -c sub.c
clean:
rm -rf *.o
rm -rf tt
::::::::::::::
sub.c
::::::::::::::
#include "csmath.h"
int sub( int a, int b)
{
return a-b;
}
::::::::::::::
test.c
::::::::::::::
#include <stdio.h>
#include "csmath.h"
int main()
{
printf("Hello,world!\n");
printf("add result: %d",add(1,3));
return 0;
}