静态链接库
来源:互联网 发布:张龙java视频 编辑:程序博客网 时间:2024/05/16 03:14
静态链接库:编译时就完成链接过程,文件名扩展名为.a
[xxx@localhost staticLibrary]$ lsmain.c test.c test.h[mapan@localhost staticLibrary]$ lsmain.c test.c test.h[xxx@localhost staticLibrary]$ cat main.c #include<stdio.h>#include"test.h"int main(){ int num=test(2,3); printf("num=%d\n",num); return 0;}[xxx@localhost staticLibrary]$ cat test.c#include"test.h"int test(int a,int b){ return a*b;}[xxx@localhost staticLibrary]$ cat test.hint test(int a,int b);[xxx@localhost staticLibrary]$
再看:
[xxx@localhost staticLibrary]$ gcc -c test.c[xxx@localhost staticLibrary]$ lsmain.c test.c test.h test.o[xxx@localhost staticLibrary]$ ar cr libtest.a test.o[xxx@localhost staticLibrary]$ lslibtest.a main.c test.c test.h test.o[xxx@localhost staticLibrary]$
调用静态库:
[xxx@localhost staticLibrary]$ gcc main.c -L. -ltest[xxx@localhost staticLibrary]$ lsa.out libtest.a main.c test.c test.h test.o[xxx@localhost staticLibrary]$ ./a.out num=6[xxx@localhost staticLibrary]$
查看库信息:
[xxx@localhost staticLibrary]$ ar tv libtest.a rw-rw-r-- 511/511 1240 Jul 26 19:52 2017 test.o[xxx@localhost staticLibrary]$
一个静态链接库可以由多个.o文件组成。
阅读全文
0 0
- 动态链接库、静态链接库;动态链接、静态链接
- 动态链接,静态链接,动态链接库,静态链接库
- VS2010 链接静态链接库
- 静态链接,静态链接库,CRT
- 编写静态链接库
- 静态链接库lib
- 静态链接库
- 创建静态链接库
- 二. 静态链接库
- 静态链接库
- 关于静态链接库
- linux-静态链接库
- 创建静态链接库
- 静态链接库
- 静态链接库
- 编写静态链接库
- 静态链接库
- 静态动态链接库
- 统计十进制数的二进制形式里数字1的个数
- 喷水装置(一)
- 【Angular4.X学习笔记一】对Angular的基础认识
- UVA: I Can Guess the Data Structure!(stl模拟)
- session和cookie的区别和联系,session的生命周期,多个服务部署时session管理
- 静态链接库
- struct struct
- 7.26欢乐爆零赛【字符串】
- NYOJ 55-懒省事的小明
- 三丶java流程控制语句,算法,方法定义
- GCD HDU
- UVA 11995 I Can Guess the Data Structure! (STL的基本操作)
- Nginx文档-初学者指南
- PAT乙级 1065. 单身狗(25)