Threads with mbed

Hello. I’m unable to use threads in my code. Here’s the error : Thread.h: No such file or directory.
Reading through other topics around here only made the situation even more confusing because of the discussion about mbed OS 5. I thought creating an mbed project would also install mbed-os. How can I install mbed-os in Platformio ?

Have a look to http://docs.platformio.org/en/latest/frameworks/mbed.html#configuration
When you create and build a mbed project, PIO will install mbed-os (not always the last release), but there is some difference to online compiler. You need to set the configuration items (see link to docs) manually, so if you need RTOS (or another part of mbed-os like network) you must add

build_flags = -D PIO_FRAMEWORK_MBED_RTOS_PRESENT

to the platformio.ini file. The reason is to get more backward compatibility to mbed2 which not
always use RTOS. mbed-os5 is meanwhile a memory killer because the code will blown up unnecessary.

1 Like

Thank you so much ! The build flag solved the issue.