目的隐藏源代码只提供给.a 与.h文件

/*
aston.c
*/
#include <stdio.h>
void func1( void )
{
 printf("func1 in aston.c\n");
}
int  func2(int a,int b)
{
 printf("func2 in aston.c\n");
 return a+b;
}
//aston.h
void func1( void );

int  func2(int a,int b);

//Makefile
all:
 gcc  aston.c -o aston.o -c
 ar   -rc  libaston.a  aston.o 

//text.c

#include "aston.h"
#include <stdio.h>

int main(void)
{
 func1();
 int a = func2(4,5);
 printf("a = %d.\n",a );
}

aston@ubuntu:~/CCC/hello/4.6.11.archiveuse$ make
gcc  aston.c -o aston.o -c
ar   -rc  libaston.a  aston.o

aston@ubuntu:~/CCC/hello/4.6.11.archiveuse$ gcc test.c -o test
/tmp/ccsEZ3M1.o: In function `main':
test.c:(.text+0xa): undefined reference to `func1'
test.c:(.text+0x1e): undefined reference to `func2'
collect2: error: ld returned 1 exit status

aston@ubuntu:~/CCC/hello/4.6.11.archiveuse$ gcc test.c -o test -laston
/usr/bin/ld: cannot find -laston
collect2: error: ld returned 1 exit status

aston@ubuntu:~/CCC/hello/4.6.11.archiveuse$ gcc test.c -o test -laston -L.  //_L.去链接当前目录
aston@ubuntu:~/CCC/hello/4.6.11.archiveuse$ ls
aston.c  aston.h  aston.o  libaston.a  Makefile  test  test.c

aston@ubuntu:~/CCC/hello/4.6.11.archiveuse$ ./test
func1 in aston.c
func2 in aston.c
a = 9.