This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NCS: How to fix broken debug built?

Dear NCS experts,

When trying to debug in VSCode by hitting F5 (or Menu: Run->Start Debugging), compilation fails with: fatal error: zephyr.h: No such file or directory
The full output looks like:

> Executing task: C/C++: arm-none-eabi-gcc build active file <

Starting build...
/home/mike/nrf-dev/tools/gnuarmemb/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gcc -fdiagnostics-color=always -g /home/mike/nrf-dev/projects/xxx/src/main.c -o /home/mike/nrf-dev/projects/xxx/src/main
/home/mike/nrf-dev/projects/xxx/src/main.c:1:10: fatal error: zephyr.h: No such file or directory
    1 | #include <zephyr.h>
      |          ^~~~~~~~~~
compilation terminated.

Build finished with error(s).

Terminal will be reused by tasks, press any key to close it.

Beside that, an error dialog pops up, complaining that main does not exist:

launch: program '/home/mike/nrf-dev/projects/xxx/src/main' does not exist.

However, the path is correct and main.c is there... The dialog has a button labeled 'Open 'launch.json', which contains:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "arm-none-eabi-gcc - Build and debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}/${fileBasenameNoExtension}",
            "args": [],
            "stopAtEntry": true,
            "cwd": "${fileDirname}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "C/C++: arm-none-eabi-gcc build active file",
            "miDebuggerPath": "/usr/bin/gdb",
            "showDevDebugOutput": true
        }
    ]
}

This happens only when trying to debug. A regular build works just fine. Any ideas how to fix this are welcome,
Thank you,
Michael.

Parents Reply Children
No Data
Related