**** Advance Notice ****

This site will be closed on 31 December 2015,

Important Information for users of NXP LPCXpresso

This site is for users of Code Red branded products.

NXP LPCXpresso users should visit the LPCXpresso FAQ's for up-to-date information relevant to that product.

Using library projects from your own projects

Note: If you are using Code Red IDE version 4.x then functionality described in the FAQ "Enhanced Static Library Support in Code Red IDE v4" can often be used instead of the methods described below.


When creating your own application projects, you may want your project to make use of library projects. Such library projects may have been created by yourself, provided in the tools suite examples (for example the RDB1768 LCD and LPCUSB libraries), or provided by 3rd parties.

In order to use such library projects, you will need to add appropriate include paths and libraries to your project. You will also need to do this for each build configuration (for example, Debug or Release).

First of all, ensure that the library project exists in the same workspace as your application project. Also ensure that the current build configuration for your project is Debug. Then...

  1. Open the Project properties. There are a number of ways of doing this. For example, make sure the Project is highlighted in the Project Explorer view then open the menu "Project -> Properties".

  2. In the left-hand list of the Properties window, open "C/C++ Build" and select "Settings" and then the "Tool Settings" tab.
  3. Now choose "MCU C Compiler - Directories" (or "MCU C Compiler - Includes", depending on tools version) and click on the "Add" icon.
  4. Now choose "Workspace" and then navigate to the directory within the library project containing any include files.
  5. Repeat step 4) if there is more than one include directories within the library project. For example if you are adding a link to the library LPC13_Lib, then what needs to appear on the include path is "${workspace_loc:/LPC13xx_Lib/inc}".
  6. If your project contains any assembler files, then choose "MCU Assembler - General" and add the include paths there too.
  7. Once you have added all the include paths, change to the other Build Configuration (Debug -> Release) in the drop down at the top of the properties window, and repeat steps 4), 5) and 6).

  8. Change the Build Configuration back to Debug.
  9. Choose "MCU Linker - Libraries" and click on the "Library search path (-L) Add" icon.
  1. Now choose "Workspace" and then navigate to the "Debug" directory within the library project. For example if you are adding a link to the library LPC13xx_Lib, then what needs to appear on the library search path is "${workspace_loc:/LPC13xx_Lib/Debug}".
  2. Now click on the "Libraries (-l) Add" icon. Type in the name of the library. This will be its project name, for example "LPC13xx_Lib". (You do not need to enter the quotes.)
  3. Now change to the other Build Configuration (Debug -> Release) in the drop down at the top of the properties window, and repeat steps 8), 9) and 10). Note that this time in step 8), you will need to navigate to the "Release" directory within the library project. Thus if you were adding a link to LPC13xx_Lib to your project, then what needs to appear on the library search path would be "${workspace_loc:/LPC13xx_Lib/Release}".

  4. Now you need to open "C/C++ General -> Paths and Symbols" in the left-hand list of the Properties window and open the "References" tab. Tick the appropriate box(es) for the library project(s) that your project uses.

  5. Finally you need to add a project reference from your application project to the library project. To do this, select "Project References" in the left-hand list of the Properties window, and tick the appropriate box(es).

Note that if your application project makes use of several library projects, you will need to repeat the above sequence for each library project.

A Note on library naming

The GNU tools require libraries to be named liblibrary_name.a. However, when you link with a library, you only use the library_name. For example, if you have a library called libmylib.a, you would link with mylib.

Also see...

LibraryProjects (last edited 2012-06-20 08:07:23 by CrSupportAb)