I have a C source code file called main.c
located in the directory:
C:\Users\arnau.blanco\OneDrive - Company\Desktop\code
I am trying to debug this file using VSCode on Windows. I have GCC, GDB, and Cygwin installed and configured, and I’m using the C++ (GDB/LLDB) debugger.
Steps to Reproduce:
I go to "Run and Debug" and click on the "Run and Debug" button.
I select the C++ (GDB/LLDB) debugger and it starts debugging, but I get the following error:
Unable to start debugging. Program path 'C:\Users\arnau.blanco\OneDrive - Company\Desktop\code\main.exe' is missing or invalid.
GDB failed with the message: /cygdrive/c/Users/arnau.blanco/OneDrive: Is a directory.
This may occur if the process's executable was changed after the process was started, such as when installing an update. Try re-launching the application or restarting the machine.
[Open 'launch.json'] [Cancel]
What I’ve Tried:
- Manually compiling the program:
gcc -g "C:\Users\arnau.blanco\OneDrive - Company\Desktop\code\main.c" -o "C:\Users\arnau.blanco\OneDrive - Company\Desktop\code\main.exe"
This works fine, and the executable is created successfully.
Running GDB manually in the terminal:
gdb "C:/Users/arnau.blanco/OneDrive - Company/Desktop/code/main.exe"
This also works as expected.
My configuration
This is my tasks.json
file:
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: gcc.exe build active file",
"command": "C:\\cygwin64\\bin\\gcc.exe",
"args": [
"-fdiagnostics-color=always",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
},
"detail": "compiler: C:\\cygwin64\\bin\\gcc.exe"
}
]
}
Questions:
- Is this error caused by the spaces in my file path (e.g.,
OneDrive - Company
)? - If so, how can I configure VSCode to correctly handle paths with spaces?
I appreciate any guidance on this! Let me know if you need more details about my setup.