5 years, 2 months ago.

Set mbed-os globally

Hi, every time that i import new embed project it clone new MBED-OS from git repo ! and its about 800M :( is there any way to save that somewhere and use globally ?! by the way I searched for this issue and I'm fully surprised!

1 Answer

5 years, 2 months ago.

Yes! I'm sure there are many ways to accomplish this and I've found a couple that work for me.

Use the mbed library as a .lib

There are plenty of resources available online on how to create a .lib file and it will be specific to your IDE on how to use this resource within your project. Essentially this compiles all your source files into one large .lib. This saves you from having to compile the many, many sources files that make up the mbed library every time your project structure changes. The .lib is much smaller than the entire mbed library, but can still be fairly large. NOTE: If you're using the mbed RTOS it is not recommended to use this option.

Use a centralized mbed library

This is probably the easiest method. Just place your mbed library in a specific directory (outside of your project directory) and you can then manage it with Git to keep it up to date. Then you'll have to change the location of your source files and header include paths within your project. This varies from IDE to IDE and because mbed has so many files it can take a long time if you do it manually. A quick trick is to open your IDE's project files with a text editor (again, this varies from IDE to IDE, but with uVision5 the file type is .uvoptx) and locate when each of the mbed source files are referenced, then change their relative path. As an example you would see "./mbed-os/features/<...>". Do a "replace all" of "./mbed-os/" to "<the new relative path>/mbed/-os/features/<...>". If you're unfamiliar with relative paths, do a little Googling on the subject. Essentially what this does is just points the IDE to all the same files and directories, just in a shared location.

Be aware that the mbed library is constantly changing and it's possible that if you try to convert a newly created project to point to an outdated shared mbed library you might run into errors due to missing files and/or pre-compiler definitions.

Good luck!

Accepted Answer

thanks for your comment, its working like any other c program :) but it'll be better if Mbed development team put some option in Mbed-cli to save mbed-os location. using MAKEFILE method or something like it.

posted by Hamid Najafi 29 Jan 2019