When you import a program to Mbed Studio from os.mbed.com, a Git hosting service or one of the built-in example programs, you also import all of the libraries on which it is dependent, including Mbed OS which is delivered as
mbed-os. You can import additional libraries to your program in order to make use of their functionality.
- When you create an example Mbed OS program, including an empty example, Mbed Studio adds the version of Mbed OS that Mbed Studio is shipped with.
- When you import an existing program, Mbed Studio adds the version of Mbed OS the imported program's
mbed-os.libfile points to.
Your program may require additional libraries, for example ones that support hardware you've added to your development board. If you import a program already using these libraries, they will be imported with your program. If you need to add additional libraries, see the Importing a library section below.
Opening the Libraries tab
The Libraries tab lists all of the libraries in an active program (indicated with the cog icon on the file list). From this tab you can view library details - such as the library version and where it was imported from - and import, remove, and update a library, or check out a specific library version.
To open the Libraries tab:
Right-click the program name in the files pane and select Set Active Program.
Select Libraries from the View menu.
The Libraries tab opens in the bottom panel.
When a library is dependent on another library, the Libraries tab presents the dependency indented under the dependent library.
Importing a library
You can import libraries to an existing program from os.mbed.com or from a Git hosting service. Each library that you add to a program is identified by a .lib file.
Note: The Mbed Studio files pane hides .lib files.
To import a library:
Click the Add new library button () on the Libraries tab.
This opens the Add Mbed Library window.
Choose whether you want to import the library from os.mbed.com or from a Git hosting service and paste the full remote URL.
Modify the library name as required, and click Next.
Specify the branch or tag you want to import.
You can view the progress of the import on the Background Tasks progress indicator, which appears at the bottom right corner of the screen. When the import is complete, the library appears on the Libraries tab and in the files pane.
Removing a library
To remove a library:
Click the Remove library button (), which appears on the right when you hover the mouse pointer over library name on the Libraries tab.
The Remove library window is displayed.
Updating a library
When you import a library to Mbed Studio from os.mbed.com or from a Git hosting service (either manually, as described above, or as a dependency for an imported program), you clone the library to your workspace.
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.
When there are updates to libraries in an active program, the Update all button at the top right corner of the Libraries tab indicates the number of updates available. Click the Update all button to view details about the available updates.
You can update all of the top-level libraries in the active program in one click, or update or check out a specific version of each library individually (next section).
Note: Updating all top-level libraries does not automatically update all library dependencies.
To update all top-level libraries in a program:
Click the Update all button () at the top right corner of the Libraries tab.
The Update all libraries window appears with details about all of the libraries for which updates are available.
Click Update all.
Updating the mbed-os library
Checking out a specific library version
To update to the latest version of a specific library, click the Update to latest button () to the right of the library name on the Libraries tab.
To check out a specific library version:
Click the chevron next to the Update to latest button to the right of the library name on the Libraries tab.
Click Check out to version.
The Update <library_name> to version... window appears.
Select a branch or tag. Note that checking out to a tag puts the library in detached head state.
Click Update Library. The library is checked out to the tip of the selected branch and the .lib file is updated.
Fixing library problems
When there are problems with any of the libraries in an active program - for example, if you do not have a library's source downloaded, or if you check out a new commit of a program that refers to a library commit you do not have checked out - the Fix all problems button at the top right corner of the Libraries tab indicates the number of fixes required.
Click the Fix all problems button to view details about the required fixes.
You can fix all of the libraries in the active program in one click, or you can fix each library individually.
To fix all library problems in a program:
Click the Fix all problems button () at the top right corner of the Libraries tab.
The Fix all problems window appears with details about all required fixes.
Click Fix all.
To fix a specific library, click the Fix problems button to the right of the library name on the Libraries tab.
Source-controlling library updates
.lib files describe the libraries in your program. To share library changes with collaborators, commit .lib file changes to your program's source control repository. Do not 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.