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:
- 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.
- From the File menu, select Add Library to Active Program.... The Add Mbed Library dialog is displayed.
- Choose whether you want to import the library from os.mbed.com or from a Git hosting service.
- Modify the library name as required and then click Next.
- 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.
- 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
"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:
- 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.
- 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.
- 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.