linux 编译静态库例子--from周立功文档

Posted dlutccj

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux 编译静态库例子--from周立功文档相关的知识,希望对你有一定的参考价值。

/* hello1.c */
#include <stdio.h>
int hello1 (void)
{
printf("hello 1! ");
return 0;
}
/* hello2.c */
#include <stdio.h>
int hello2 (void)
{
printf("hello 2! ");
return 0;
}

[email protected]:libhelloa$ gcc -c hello1.c hello2.c
生成2个.o文件

[email protected]:libhellloa$ ar -r libhello.a hello1.o hello2.o
ar: creating libhello.a
生成libhello.a

调用如下

/* hello.c */

#include <stdio.h>
int hello2 (void)
{
  hello1();

       hello2();

gcc hello.c libhello.a























以上是关于linux 编译静态库例子--from周立功文档的主要内容,如果未能解决你的问题,请参考以下文章