当前位置:网站首页>创建静态库的基本步骤
创建静态库的基本步骤
2022-07-17 07:45:00 【Charmchin】
开始创建的目录情况如下:

创建的几个文件分别是:
1,pmath.h
#ifndef P_MATH_H //头文件卫士 #define P_MATH_H //函数的声明 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; }
我这里是在同一目录下创建的这四个文件,所以我需要将 test.c 移动到上级目录。( 当然你也可以直接在上级目录创建 test.c :)

将要加入静态库的文件编译为目标文件。链接 .c 文件生成 .o :

将目标文件添加到静态库(creating libImath):

查看:

使用静态库链接生成可执行文件并执行:

目录结构 :


边栏推荐
- The core problem of concurrent programming
- be vigilant! Another phishing attack: uniswap stolen $8.1 million
- Gateway new generation gateway
- Dark horse programmer - software testing -16 stage 3 - function testing -175-198, URL composition introduction, request content and composition description line function test and database, URL composi
- Not so large number of combinations
- Snap 1669 combine deux notes de liste
- Li Kou 43 string multiplication note
- With this "programmer code interview guide" from Zuo Chengyun (Zuo Shen), I joined byte
- sudo pip install gevent 安装失败的解决办法
- 美国压力激增,TikTok 更换全球安全主管
猜你喜欢
随机推荐
《Flutter入门》flutter计算最近1个月、3个月、半年、12个月
力扣455分发饼干笔记
60. Initial knowledge of wsgiref handwritten web framework +jinja2 module
Sword finger offer 42 Maximum sum dynamic programming method for continuous subarrays
力扣912排序数组笔记
Redis6 新数据类型——Geospatial
Unity: window size adaptation when running on the browser after webgl Publishing
Eureka自我保护
New redis6 features
5.2 database security
visual studio 2022(VS 2022)无法读取内存的问题
WebGL的CPU负载问题-WebGL对比
總結的太好了!終於有人把SQL的各種連接Join都講明白了
5g at that time, where will driverless driving go in the future?
STM32CUBEIDE(9)----USART通过DMA收发
php存储密码
Dependency injection method
5.1 安全漏洞與防範
Redis introduction
matlab导入小数点后9位以上的浮点数









