当前位置:网站首页>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 :


边栏推荐
- WVPPRO-ZLM-GB21818-摄像头
- Obtain the home location through IP
- Introduction to flutter flutter calculates the last 1 month, 3 months, half a year, 12 months
- Solution to sudo PIP install gevent installation failure
- Dependency injection method
- 5.1 安全漏洞與防範
- visual studio 2022(VS 2022)无法读取内存的问题
- Ribbon负载均衡服务调用
- ansible自动化运维详解(四)ansible中playbook的编写使用、执行命令及实例演示
- Redis6 新数据类型——Geospatial
猜你喜欢
随机推荐
1、flask基础
手把手实践一个DAPP,通往Web3.0之路!
Address monitoring API: how to trace and monitor uniswap hacker addresses
Redis 概述安装
石墨厚度测量
How to select MCU?
力扣1669合并两个链表笔记
TextView文字上下移动
Introduction to flutter flutter calculates the last 1 month, 3 months, half a year, 12 months
46. IO model
Redis6 新数据类型——Geospatial
matlab导入小数点后9位以上的浮点数
Viewing the technology stack of distributed system from the crash report of station B
Use of OpenCV polar transformation function warppolar
百度Apoll
Solutions to license invalidation caused by MATLAB update
Spark miscellaneous -- why reuse exchange and subquery
Excellent résumé! Enfin quelqu'un a compris toutes les connexions SQL
事件循环、宏任务、微任务
Eureka Basics









