Error: cannot open source file mbed.h

Hello,

I m trying to program mBED LPC1768 board using mBED CE platform. What I have done is I followed the steps for installation of Visual studio and required extension. I installed CMake and GNU also. But I am getting the error: cannot open source file mbed.h. Kindly help me anyone.

Hello,

did you already select necessary settings in CMake extension panel? Especially Build variant (Debug NUCLEO_F767ZI in case below).

image

Point 7 of Project Setup: VS Code · mbed-ce/mbed-os Wiki (github.com)

BR, Jan

I followed the same but, the variant(mBED LPC 1768) was not shown in the list.

OK, so the build variant was not set, you can not start CMake and that is the reason of the error. Then go two steps back, point 5. The file cmake-variants.yaml is probably missing in your project or it is not filled correctly.
It should look like

buildType:
  default: Develop
  choices:
    Develop:
      short: Develop
      long: Emit debug information but also optimize
      buildType: Develop
    Debug:
      short: Debug
      long: Emit debug information and don't optimize
      buildType: Debug
    Release:
      short: Release
      long: Optimize generated code
      buildType: Release
board:
  default: LPC1768
  choices:
    YOUR_MBED_TARGET:
      short: LPC1768
      settings:
        MBED_TARGET: LPC1768
        # Fill your upload method according to variants below
        # - universal: NONE, MBED, JLINK, PYOCD, OPENOCD
        # - target specific: STLINK, STM32CUBE, LINKSERVER, PICOTOOL, ARDUINO_BOSSAC
        # For more visit - https://github.com/mbed-ce/mbed-os/wiki/Upload-Methods#upload-method-list
        UPLOAD_METHOD: NONE

BR, Jan

I chose the Upload method as MBED
And now the variant is also showing as Develop + MBED LPC1768. But still it is exit with 1.## cannot open source file mbed.h
This error is I am seeing. And I did not follow step 6 which I did not understand.

In the CMakeLists Text document, at include(mbed-os/tools/cmake/app.cmake), I am seeing the error of “include could not fine requested file”. How to add mbed-os folder to my project?

We can look on this later.

New Project Setup Guide · mbed-ce/mbed-os Wiki (github.com)

BR, Jan