Mistake on this page? Email us

Including libraries

When you import a program to Mbed Studio from os.mbed.com, a Git hosting service or one of the built-in example programs, it is imported with all its dependent libraries, including mbed-os.lib. You can import additional libraries to your program in order to make use of their functionality. Mbed Studio indicates when updates are available for a library.

A library is associated with a specific program in your workspace. If you have multiple programs that use a particular library, you will have multiple copies of the same library; one per program. Each copy of the library can be at a different commit, and updating a library for one program does not update other copies of that library.

Importing a library

You can import libraries from os.mbed.com or from a Git hosting service to add to an existing program. Each library that has been added to a program is identified by a .lib file.

To import a library:

  1. Ensure the program that you want to add the library to is active. To make the program active, right-click the program name and select Set Active Program.
  2. From the File menu, select Add Library to Active Program.... The Add Mbed Library dialog is displayed.
  3. Choose whether you want to import the library from os.mbed.com or from a Git hosting service.
    • You can browse for Mbed libraries at os.mbed.com/code.
    • To import a library from os.mbed.com or from a Git hosting service, paste the full URL of the web page.
  4. Modify the library name as required and then click Next.
  5. Specify the branch, tag, commit SHA or revision ID that you want to import. Note: If you select a tag or commit SHA/revision ID, the library will be in detached head state when it is imported.
  6. Click Finish. The library directory and a corresponding .lib file are added to your program.

Updating a library

When a library is imported to Mbed Studio from os.mbed.com/code or from a Git hosting service (either manually, as described above, or as a dependency for an imported program), it is cloned to your workspace.

If there are updates available to libraries in a program, "R" is displayed to the right of the program name and next to the .lib file of the library that can be updated. Select the .lib file to open the Mbed Libraries tab and view more details about the library, including the current branch and/or commit. "W" indicates a mismatch between the contents of the mbed-os folder and the mbed-os.lib file.

"R" and "W" library statuses.

To update a library to the latest version: In the files pane, right-click the library you want to update and select Update Library to Latest Version....

You can also select the library directory or the corresponding .lib file for the library that you want to update. The Mbed Libraries pane is opened and displays details of the selected library, including the current branch. Click Update. The library is updated to the tip of the current branch, or to the tip or master if the library was in detached head state.

If the library is on a branch, you can update it to the tip of the branch. If the library is in detached head, you can update it to the tip of master.

To update a specific branch, tag or commit SHA/revision ID:

  1. In the files pane, right-click the library you want to update and select Update Library to Version.... The Update <library_name> to version... dialog is displayed.
  2. Select a branch or tag, or enter a commit SHA or revision ID. Note that checking out to a tag or commit SHA/revision ID will put the library in detached head state. Tip: To check out a released version of Mbed OS, select Tag and select the version number from the drop-down list.
  3. Click Update Library. The library is checked out to the specified commit or the tip of the selected branch and the .lib file is updated.

Source-controlling library updates

If your program is a source-controlled repository, add and commit the changes to the .lib file of the library. You do not need to add the library directory and its contents to your program repository. Note: The .lib file only identifies the commit that you are using; it does not include branch information. In Mbed Studio, you can check out a library to the tip of a specific branch, but this information will not be included if you open your program repository in another application, or if you push changes to a remote repository.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.