This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Visual code: boards.h not found

I'm using visual code for my development. I've tested a basic hello world app, this works fine so c/cpp is correctly installed.

I'm now testing a basic app, but I'm getting the error, boards.h: No such file or directory. When I "F12" on the functions I do get into the boards.h file. I've added the SDK to my settings.json in visual code (which is why i can F12 to the correct file):

    "C_Cpp.default.includePath": [
        "D:/nRF5_SDK_17.0.0_9d13099/**",
        "D:/nRF5_SDK_17.0.0_9d13099/components/**",
        "D:/nRF5_SDK_17.0.0_9d13099/components/libraries/**",
        "D:/nRF5_SDK_17.0.0_9d13099/components/boards/**",
        "{$workspaceFolder}/components/libraries/**",
        "{$workspaceFolder}/libraries/**",
        "{$workspaceFolder}/**",
    ],
But I think the compiler (I'm using GCC from mingw) isn't including the sdk. Which step do I have to take to enable it to use the SDK, or did I make another mistake?

For those trying the same:

To setup my Visual code to use c/cpp I followed this video: https://www.youtube.com/watch?v=Ubfgi4NoTPk
In Visual code I've added two extension: "c/cpp" & "code runner"
To adjust my json config I followed the answer of Vitox in: https://stackoverflow.com/questions/37522462/visual-studio-code-includepath 

Parents Reply Children
  • To extend this answer:

    Install GNU Make from the reference above (http://gnuarmeclipse.github.io/windows-build-tools/). Go to the path that you installed this in and copy this path (recommended to follow the instructions for installation on the site)
    For me this was 'C:\Users\james\AppData\Roaming\GNU MCU Eclipse\xpack-windows-build-tools-2.12.2\bin'


    ref. the docs:

    The Windows versions of GNU MCU Eclipse Windows Build Tools are packed as ZIP files. Go to the  GitHub Releases page and download the latest version named like:

    • gnu-mcu-eclipse-build-tools-2.10-20180103-1919-win64.zip
    • gnu-mcu-eclipse-build-tools-2.10-20180103-1919-win32.zip

    Select the -win64 file for Windows x64 machines and the -win32 file for Windows x32 machines.

    Unpack the archive and copy it into the %userprofile%\AppData\Roaming\GNU MCU Eclipse (for example C:\Users\ilg\AppData\Roaming\GNU MCU Eclipse) folder.

    Then add the path variable to you enviroment variables. Ref. https://youtu.be/Ubfgi4NoTPk?t=407
    In this video MinGW is also installed so if you can't compile C++ you can follow that same video to get a compiler for C++.

    After doing this step restart visual code, you can check if it worked by typing 
    make -v

    ----------

    In visual code, don't forget to update "/components/toolchain/gcc/Makefile.windows"
    you need to reference your GNU folder, I had to update both path and version:

    GNU_INSTALL_ROOT := C:/Program Files (x86)/GNU Arm Embedded Toolchain/9 2020-q2-update/bin/
    GNU_VERSION := 9.3.1
    GNU_PREFIX := arm-none-eabi

Related