how to product static link lib .a file
来源:互联网 发布:免费snmp网络管理软件 编辑:程序博客网 时间:2024/06/07 10:43
http://blog.csdn.net/wxdcxp/article/details/4641898
本文主要介绍用gcc编译生成静态链接库*.a文件的方法.
我们知道.a文件就是几个.o文件合在一起用于静态链接.
假设我们有如下四个文件
[cpp] view plaincopyprint?
- /**********************************
- *文件main.c
- ***********************************/
- #include <stdio.h>
- int main()
- {
- F1();
- F2();
- F3();
- printf("A/n");
- printf("B/n");
- return 0;
- }
- /****************************************
- *文件file1.c
- *****************************************/
- void F1()
- {
- printf("F1/n");
- }
- /****************************************
- *文件file2.c
- *****************************************/
- void F2()
- {
- printf("F2/n");
- }
- /****************************************
- *文件file2.c
- *****************************************/
- void F3()
- {
- printf("F3/n");
- }
分别用用命令gcc –c main.c
Gcc –c file1.c
Gcc –c file2.c
Gcc –c file3.c
可以生成四个.o文件,分别是mian.o file1.o file2.o file3.o
然后用ar –r lib.a main.o file1.o file2.o file3.o
即可以生成一个lib.a 的打包文件.
如果要编译代码,我们可以用命令gcc –o test lib.a
即可以生成一个test.exe 的可执行文件
- how to product static link lib .a file
- How to make a direct download link to a static file
- How to load Properties file from a static block or static method
- How To Create a Featured Product
- How to build a product with InstallShield
- How to open a file
- How to create a link in Linux
- How to make Universal Static library (.a file) in iOs using xCode
- how to build a codec using lib
- How to extract .obj from a .lib
- link error Unable to open file 'dclusr50.lib'
- how to compile and link static/dynamic library in linux
- C++ How to tell if a .lib file was compiled with compiler option /MT, /MD, /MTd, /MDd, /clr etc?
- How to write a product backlog step by step
- How to protect shader code in a release product
- How to add a .dll file ?
- how to test a file 's existence
- how to make a JAR file
- Android 检查WIFI是否可用的实现方法
- UML中聚合和组合的区别
- poj 3277
- 整数数组0元素后移
- 大话设计模式_建造者模式
- how to product static link lib .a file
- 元数据包含无法解析的引用:“http://169.254.80.80:83/WS_Login.asmx”。
- IOS-iphone真机免证书调试
- CXF2.7.3 与spring 3集成 .
- 全区全服PVP服务器管理策略
- 菜鸟学做seo全套教程
- Java开源建站工具
- A. Chat room
- 读书笔记之《设计模式解析》读后总结