How to generate and use static library in CoIDE overview
Transcription
How to generate and use static library in CoIDE overview
How to generate and use static library in CoIDE overview Reasonable use of static library can greatly reduce the compile time and improve the development efficiency in large project. It’s easy to creat and use a static library in CoIDE project.The next step we will demonstrate how to do that.(CoIDE 1.7.5). Note: 1) With other CoIDE version, the operation is same as this document, please see the corresponding Help Contents in details. 2) If it’s your first time to use CoIDE, we suggest you see the CooCox Getting Start series documents first. 1. Open the CoIDE, the main interface as below 2. Crteat a new project named Guide_UseStaticLib 3. Select chip mode, then clink Next 4. Type in “103VE” In the search box, CoIDE will screen out Chips which include this fields automatically. As the follow image, here we select STM32F103VE chip, then clink Finish button. 5. Clink to select GPIO component, and add example GPIO Blink to it, then compile Note: If you don’t know this step clearly, please the the document “How to use CoX library in CoIDE”. 6. In order to creat static library(*.a), we should mainly do two aspects 1) In the configuration page of the project, clink to select “Crteat Library(.a)” in the Output label. 2) Only keep the source files which need to be compiled into static library(*.a). Generally, we would reserve the source files which are not often changed(eg CMSIS library, CoX library). So, here we delete Blink.c, main.c, startup.c files in the project, then goto the Congiruration page and select “Crteat Library(.a)” in the Output label. 7. After step 6, we rebuild the project, then the new static library libGuide_UseStaticLib.a will be cteated in the project direction Debeg\bin. Note: A prefix “lib” will be added automatically to the created static library when compiled by GCC, it’s name rules is libxxx.a, here “xxx” is our CoIDE project name. More information, please reference to GCC Manual. 8. Next we creat a folder named StaticLib under the project direction, and copy the created static library into it. 9. Essentially static library is a collection of .obj files which are created from .c files, it can improve the compile&link speed of the project, because some compile&link process has been reduced. Next steps are 1) Delect all the files which are under the direction tree CoX_Peripheral\src 2) Add Blink.c, main.c, startup.c files to the project again. 3) Modify the project configuration, select “Creat Executable(.elf)”. After modify, rebuild the project, CoIDE will creat elf and bin, hex files. As the follow image.