当前位置:网站首页>Generation and use of Lib library files in keil and IAR
Generation and use of Lib library files in keil and IAR
2022-07-28 11:04:00 【tutu-hu】
One .lib The use of static libraries has the following advantages :
1. Encapsulate source code , Not open to the outside world , Improve confidentiality .
2. Encapsulate standard function functions into libraries , Improve code reusability .
3. Use the library to develop , Simplify development process , Improve development efficiency .
4. System call library functions , Improve execution efficiency .
Two .keil In the environment Lib Library generation
1. Modify the compilation output mode to Create Library, That is, the output is created lib library , And in 2 The name of the input warehouse .
2. Select the file that needs to be compiled as a library , That is, exclude files or folders that do not need to be compiled from compilation .
First, select the file or folder that does not need to be compiled and right-click , choice options… Options , As shown below :
And then include in Target Build Uncheck the option box , As shown below :
3. After selection, the system project folder is as follows , It can be seen that only hututu_test.c Files participate in compilation .
4. After recompiling the whole project, the output is as follows :
5. After compilation, it can be generated in the selected output folder .lib file 
thus lib Library generation succeeded .
3、 ... and .keil In the environment Lib Library call
lib After the library is generated, you need to call the Library , To replace the original c file , The specific steps are as follows :
1. First, change the system compilation output option to executable , As shown below :
2. take lib Add files to system engineering 
3. Will participate in the compilation before c Remove files from the system ( Because the library file replaces the function of this part of the code )
4. Recompile project , give the result as follows , It can be seen that the library file is effective . Replaced the original part c Role of documents .
thus , The call test of the library file ends .
Four .IAR In the environment Lib Library generation
1. Modify the compilation output mode to Output---->Library, That is, the output is created lib library , And in 2 Select the path to save the library and enter the name of the Library .

2. Select the file that needs to be compiled as a library , That is, exclude files or folders that do not need to be compiled from compilation .
First, select the file or folder that does not need to be compiled and right-click , choice options… Options , Then check it out. Exclude from build, That is to exclude compilation , In the end, there is nothing left hututu_test.c Files participate in compilation , As shown below :
3. Recompile the results of the whole project and the generated lib The file is shown below :
thus , The whole project compiles and generates Lib File complete .
5、 ... and .IAR In the environment Lib Library call
lib After the library is generated, you need to call the Library , To replace the original c file , The specific steps are as follows :
1. First, change the system compilation output option to executable , As shown below :
2. take lib Add files to system engineering 
3. Will participate in the compilation before c Remove files from the system ( Because the library file replaces the function of this part of the code )
4. Recompile project , give the result as follows , It can be seen that the library file is effective . Replaced the original part c Role of documents .

thus , The call test of the library file ends .
6、 ... and . summary
keil and IAR Of lib The generation and invocation of static libraries are basically consistent , The use of static library can greatly simplify the complexity of the project . The generation of static libraries is only for source files (.c file ) Encapsulation , Not designed .h The header file , therefore lib The use of the library needs to cooperate with the header file ( Just use lib Replaced many .c file ), After we package lib When the library is to be used by others , Only need to lib Kuhe .h Just send the document to others , Convenient and efficient .
边栏推荐
- Status Notice ¶
- Array related knowledge points
- ctf技能树----文件上传
- 6. MapReduce custom partition implementation
- Nodejs:mongodb 简单模糊+分页查询实例
- keil和IAR中lib库文件的生成和使用
- Do data analysis, do you still not understand RFM analysis method (model)?
- GKCoherentNoiseSource
- Yan reported an error: could not find any valid local directory for nmprivate/
- 分体式测斜探头安装要点及注意事项
猜你喜欢

GKCheckerboardNoiseSource

The 10th Landbridge cup embedded electronic provincial competition

Inventory: 6 books teach you the necessary skills for career promotion

Why is low code (apaas) popular again recently?

CRM+零代码:轻松实现企业信息化

Sword finger offer 30. stack containing min function

Sword finger offer 06. print linked list from end to end

盘点:6本书教会你职场晋升必备技能

Software designers ask 20 questions before the exam, pay attention!!

Inventory: 144 free learning websites, the most complete collection of resources in the whole network
随机推荐
Sword finger offer 30. stack containing min function
Invalid ROM Table原因及解决办法
const与指针的组合使用
10_ UE4 advanced_ Add fall and cast actions
剑指 Offer 30. 包含min函数的栈
Nodejs: detect and install the NPM module. If it is already installed, skip
Arduino Basics
Advance.ai sailing guide helps enterprises sail to Indonesia and grasp half of the Southeast Asian market
If you don't climb mountains, you don't know the height of the sky; If you don't face deep streams, you don't know the thickness of the earth
几个数据库的相关概念
Pyqt5 rapid development and practice 4.11 drag and clipboard
Pyqt5 rapid development and practice 4.13 menu bar, toolbar and status bar and 4.14 qprinter
蓝桥杯嵌入式-HAL库-ADC
samba学习
Crm+ zero code: easily realize enterprise informatization
GKPerlinNoiseSource
网络文件系统服务(NFS)
GKNoise
Pyqt5 rapid development and practice 4.12 calendar and time
Eslint, Eslint中文文档