How to create a library project and use it in executable project

From SEGGER Wiki
Jump to: navigation, search

SEGGER Embedded Studio can not only be used to create executable projects but also library projects can be created. This article will show how a library project can be created in the same solution as an executable project and being used in the latter.

Example Setup

The setup guide will be based on the following software component:

  • Embedded Studio V4.18 or later

The example project can be found here: SES_Library_Example

Setup Guide

  1. Create a new executable project in a new solution for your target device
  2. Create a new library project in the same solution
  3. Add your library .c and .h files to the library project and build the library
  4. Use the library functions in your executable main application
  5. In Project Settings under Code->Build->Project Dependencies set the executable project to be dependent of the library project. This ensures that the library project will always be build before the executable project and that it will be linker properly.
  6. Build and run the executable application with your new library

Note: If you are simply looking to add a library to your project without project dependencies you can do so either via project option "Additional Input Files" or by adding the library to your project via drag & drop in project explorer.