There is no special option in Kinetis Design Studio ‘New Project Wizard’ (NPW) to create a library (or archive). But it is really easy to create a library project.
This post shows how to create a library project in the Freescale Kinetis Design Studio (KDS) (version v2.0.0 used). But this approach applies to any Eclipse based IDE using the GNU ARM Eclipse plugins.
The approach is very simple:
- Create a normal project with the NPW
- Transform it into a library project
Creating the Project
After I have created a project with File > New > Kinetis Design Studio project:
Static Library Artifact Type
The first step is to transform the project type from an ‘Executable’ into a ‘Static Library’ one. The setting is in the project properties (menu Project > Properties > C/C++ Build > Settings > Build Artifact)
Change it to ‘Static Library’:
The artifact (output file of the build) extension and prefix get automatically adjusted. This concludes the settings of the project, it is really that easy.
Removing not needed files
The next step is to remove application specific files which have been added to the project by the wizard:
- Linker Files: the library does not need a linker file, the library is a collection of object files only.
- Startup Code: the startup code belongs to the application, usually the library does not provide the startup code.
- Debugger configuration and launch configuration files: we are debugging the application from the application project, not with the library project.
- Main.c: typically the library consists of library modules, and does not have a main(). So we can remove this file too.
So select the above files and delete them from the project (DEL key or use the context menu and use ‘Delete’).
Adding Library Functionality
After that, I can add the library functionality and files to the project. In this example I add an AES encryption functionality to the library:
Building the Library
Building the library is like building an application: use one of the Project > Build to build it.
With this, the library (or archive) file will show up in the project:
With this, I have created a library project. And I can add further files and functionality to the library.
To create a library with Kinetis Design Studio, create a normal application project, change the Artifact Type to ‘Static Library’, remove the application specific files (debugger files, linker file, startup code and main()). Then I can use it as a library project.
Happy Libraring 🙂