当前位置:网站首页>Basic steps for creating a static library
Basic steps for creating a static library
2022-07-19 08:35:00 【Charmchin】
The directory you started to create is as follows :

The files created are :
1,pmath.h
#ifndef P_MATH_H // Head file guard #define P_MATH_H // Declaration of functions int p_add (int x, int y); int p_sub (int x, int y); int p_mul (int x, int y); int p_div (int x, int y); #endif2,p_add.c
#include "pmath.h" int p_add (int x, int y) { return x + y; } int p_sub (int x, int y) { return x - y; }3,p_mul.c
#include "pmath.h" int p_mul (int x, int y) { return x * y; } int p_div (int x, int y) { return x / y; }4,test.c
#include "Imath/pmath.h" #include <stdio.h> int main (void) { int a = 6, b = 2; printf (" %d + %d = %d\n", a, b, p_add (a, b)); printf (" %d - %d = %d\n", a, b, p_sub (a, b)); printf (" %d * %d = %d\n", a, b, p_mul (a, b)); printf (" %d / %d = %d\n", a, b, p_div (a, b)); return 0; }
I created these four files in the same directory , So I need to put test.c Move to the parent directory .( Of course, you can also create directly in the parent directory test.c :)

Compile the file to be added to the static library into the target file . link .c File generation .o :

Add the target file to the static library (creating libImath):

see :

Use static library links to generate executable files and execute :

Directory structure :


边栏推荐
- leetcode:287. Find the repetition number [fast and slow pointer board]
- 力扣1669合并两个链表笔记
- Junit5
- SPARK中的FileSourceStrategy,DataSourceStrategy以及DataSourceV2Strategy
- Yyds dry inventory cross origin cross domain request
- Redis介绍
- WVPPRO-ZLM-GB21818-摄像头
- With this "programmer code interview guide" from Zuo Chengyun (Zuo Shen), I joined byte
- xgen 毛发guide历史被清理解决方法
- How to select MCU?
猜你喜欢
随机推荐
Error received from peer ipv4/connection reset by peer paddleserving
Enjoy JVM -- knowledge about GC garbage collection
Redis常用数据类型——哈希(Hash)和有序集合 Zset(sorted set)
美国压力激增,TikTok 更换全球安全主管
深度学习之线性回归+基础优化
创建静态库的基本步骤
matlab导入小数点后9位以上的浮点数
46、IO模型
Consul service registration and discovery
Quanzhi v3s learning record (13) use of ov2640
SPARK闲杂--为什么复用Exchange和subquery
trochvision中数据集的使用
5.1 安全漏洞与防范
Gateway new generation gateway
SPARK中的FileSourceStrategy,DataSourceStrategy以及DataSourceV2Strategy
Li Kou 43 string multiplication note
Redis publishing and subscription
网传USDT和USDC要做空?带你一探究竟 | Tokenview
Redis6 新数据类型——Geospatial
C # read and write txt files








