当前位置:网站首页>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 .
边栏推荐
猜你喜欢

21. Merge two ordered linked lists

为什么传输前要进行编码与调制

Do you want to enroll in class for advanced soft exam

Configuring raspberry pie, process and problems encountered

Crm+ zero code: easily realize enterprise informatization

蓝桥杯嵌入式-HAL库-ADC

BC35 NB模块AT指令开发总结

Zero code | easily realize data warehouse modeling and build Bi Kanban

这里有一份超实用Excel快捷键合集(常用+八大类汇总)

keil和IAR中lib库文件的生成和使用
随机推荐
keil和IAR中lib库文件的生成和使用
蓝桥杯嵌入式-HAL库-SYSTICK
clo*******e:项目管理随记
ICML 2022 | graph represents the structure aware transformer model of learning
Semeval 2022 | introducing knowledge into ner system, aridamo academy won the best paper award
Judge whether the nixie tube is a common anode or a common cathode
MySQL Architecture Principle
蓝桥杯嵌入式-HAL库-ADC
02.1.2. logic type bool
The future of generating confrontation networks in deepfake
CGAL compilation error
用手机对电脑进行远程关机
GKBillowNoiseSource
RHEL 6.4 安装svn和apache
剑指 Offer 09. 用两个栈实现队列
使用共用体union及指针测试大小端
GKRandom
GKSpheresNoiseSource
学会这些分析方法及模型,遇到问题不再没思路
表格数据处理软件,除了Excel还有什么?