静态库创建与ar命令的使用
来源:互联网 发布:手机淘宝在哪投诉卖家 编辑:程序博客网 时间:2024/06/17 21:34
文件h1.c
#include<stdio.h>void fisthello(){printf("Fist Hello.\n");}
文件h2.c
#include<stdio.h>void secondhello(){printf("Second Hello.\n");}
文件hello.h
#ifndef _HELLO_H_#define _HELLO_H_extern void firsthello();extern void secondhello();#endif文件main.c
#include"hello.h"void main(){firsthello();secondhello();}
命令:
gcc -c h1.c
gcc -c h2.c
gcc -o hello main.c h1.c h2.c
./hello
用ar命令创建静态库
ar -rcs libhello.a h1.o h2.o
参数r:在库中插入模块(替换)。当插入的模块名已经在库中存在,则替换同名的模块。如果若干模块中有一个模块在库中不存在,ar显示一个错误消息,并不替换其他同名模块。默认的情况下,新的成员增加在库的结尾处,可以使用其他任选项来改变增加的位置。
参数c:创建一个库。不管库是否存在,都将创建。
参数s:创建目标文件索引,这在创建较大的库时能加快时间。(补充:如果不需要创建索引,可改成大写S参数;如果.a文件缺少索引,可以使用ranlib命令添加)
调用:gcc -o hello main.c -L. -lhello
显示库文件中有哪些目标文件,只显示名称命令ar -t libhello.a
h1.o
h2.o
显示库文件中有哪些目标文件,显示文件名、时间、大小等详细信息。
$ar -tv libhello.a
rw-rw-r-- 1000/1000 1024 Jul 26 06:43 2012 h1.o
rw-rw-r-- 1000/1000 1028 Jul 26 06:38 2012 h2.o
显示库文件中的索引表命令$nm -s libhello.a
Archive index:firsthello in h1.osecondhello in h2.oh1.o:00000000 T firsthello U putsh2.o: U puts00000000 T secondhello
- 静态库创建与ar命令的使用
- linux的ar命令---创建静态库
- 创建并使用静态库(ar 命令)
- Linux下静态库的创建----ar命令的使用详解
- Linux下静态库的创建----ar命令的使用详解
- linux创建静态库ar命令的使用说明
- linux命令 ar 创建静态库
- ar命令创建静态库和动态库创建方法
- 我使用过的Linux命令之ar - 创建静态库.a文件/关于Linux静态库和动态库的分析
- Linux命令之ar - 创建静态库.a文件
- Linux命令之ar - 创建静态库.a文件
- linux命令之ar—创建静态库.a文件
- Linux命令之ar - 创建静态库.a文件
- Linux命令之ar - 创建静态库.a文件
- linux命令之ar—创建静态库.a文件
- Linux命令之ar - 创建静态库.a文件
- 利用ar创建静态库
- 使用ar命令查看静态库中目标文件
- 使用sql_trace/10046事件进行数据库诊断
- @html.ActionLink的几种参数格式
- Windows系统下搭建Android开发平境
- 数据库对象命名
- 何为IMEI码
- 静态库创建与ar命令的使用
- 编写Android通知示例
- Fla制作元件导出SWC
- 跟我学jquery(六)jquery中事件详解 .
- 优化UITableView性能
- Win7+vs2010+qt4.8
- 推荐一个vps,最低端的配置非常便宜,只要550RMB左右一年
- ARX创建块遭遇图形数据库问题
- Android ApiDemos示例解析(85):Graphics->Vertices