linux静态库
来源:互联网 发布:双色球软件2016破解 编辑:程序博客网 时间:2024/06/06 05:52
静态库 1、创建静态库(1)写个静态库函数代码 //static_lib.c int add(int a,int b) { return a + b; } int sub(int a,int b) { return a - b; } int mul(int a,int b) { return a * b; } int div(int a,int b) { return a/b; } (2)编译该源文件 $gcc -c static_lib.c (3)使用ar工具创建一个静态库 ar rcs 静态库名 目标文件1 目标文件2...目标文件n 2、使用静态库(1)创建一个文件,声明静态库中全局变量和函数的声明 //static_lib.h extern int add(int a,int b); extern int sub(int a,int b); extern int mul(int a,int b); extern int div(int a,int b); (2)写一个主函数,使用库文件中的函数 #include #include "static_lib.h" int main(void) { int a,b; printf("please input a and b\n"); scanf("%d%d",&a,&b); printf("the add : %d", add(a,b)); printf("the sub : %d", sub(a,b)); printf("the mul : %d", mul(a,b)); printf("the div : %d", div(a,b)); return 0; } (3)生成可执行文件,使用-static连接静态库 $gcc main.c -static ./static_lib.a -o app
0 0
- Linux下静态库
- linux sqlite 静态库
- linux静态库
- Linux静态库
- Linux创建静态库
- Linux静态库
- linux-静态链接库
- Linux使用静态库
- #linux 打包 静态库
- Linux 动态/静态库
- linux下静态库
- 使用Linux静态库
- linux静态库制作
- linux 打包 静态库
- 编写linux静态库
- 【linux】 静态库编译
- linux 静态库,makefile
- Linux之静态库
- POJ 1661 Help Jimmy (DP)
- Codeforces Round #277.5(Div. 2) C. Given Length and Sum of Digits...【贪心】
- The KITTI Vision Benchmark Suite之Displets: Stereo using Object Knowledge
- TreeMap集合特点、排序原理
- BZOJ1016: [JSOI2008]最小生成树计数
- linux静态库
- javascript编写活动倒计时
- ZOJ-1094-Matrix Chain Multiplication
- unit15 系统虚拟机管理
- LeakCanary用法(内存泄漏检查)
- 【HTML】表格样式
- Opencv----图像细化
- poj 2236 Wireless Network
- 【UOJ #228】 基础数据结构练习题