STM32 study notes: the production and application of Keil project Lib library files

Publisher:梅花居士Latest update time:2017-09-09 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

I recently looked at the Baidu bracelet open source project and found that all the algorithms were encapsulated into a lib file. This is the first time I have learned to call it in Keil.


The question arises: Why should it be made into a lib library?

1. In order to keep the key source code written by some solution companies from being public, but at the same time the library files need to be able to be called normally by others, encapsulating them into a lib format is a good method.

2. It is very time-consuming to compile some project files. For example, when compiling UCGUI and ST official libraries, due to the large number of files, it may take one or two minutes to compile once. At this time, you can package them into a library. When compiling the project, the library files will not be compiled again, saving a lot of time.

The only downside is that you can't use the right-click "go to Definition 'XXX'" to directly find the source file definition. But generally, others package it into a lib after testing.

Production method: Taking UCGUI as an example

Step 1: Open a project that has passed the test. (If there is an error in the code in the library file to be packaged, it will not be usable after being packaged into a library. This step is critical)

After the test is successful, delete the unnecessary parts, as shown below.

Step 2: Open KEIL  MDK ->Project->Option for target...->Output and select Create Executable:.... option.

Step 3: Recompile and you can find the *.lib file in the directory where the Hex file was originally generated.

 

Open the original project, just remove the original .c file and add the .lib file to use it (the program call must include all the header files of the c file in the lib file).

Special attention should be paid to the fact that the Lib files should be divided into smaller parts, and two functions that have no calling relationship should not be placed in the same C file. It is best to place a function that has no calling relationship in a separate .c file. This is to avoid alarms when the application calls the lib library in Keil.


Keywords:STM32 Reference address:STM32 study notes: the production and application of Keil project Lib library files

Previous article:STM32 learning notes hardware SPI reading and writing and polarity setting
Next article:STM32 study notes: standby wake-up

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号