3

I've just started to use VSCode, I meet this error and try some ways to fix but it doesn't work.

This is my launch.json

{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    {
        "name": "C/C++: Build and debug active file",
        "type": "cppdbg",
        "request": "launch",
        "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
        "args": [],
        "stopAtEntry": false,
        "cwd": "${workspaceFolder}",
        "environment": [],
        "externalConsole": true,
        "MIMode": "gdb",
        "miDebuggerPath": "C:\\TDM-GCC-64\\gdb64\\bin\\gdb.exe",
        "setupCommands": [
            {
                "description": "Enable pretty-printing for gdb",
                "text": "-enable-pretty-printing",
                "ignoreFailures": true
            }
        ],
        "preLaunchTask": "C/C++: g++.exe build active file"
    }
]

} enter image description here

4 Answers 4

9

Problem fixed by doing these steps below.

Go to Windows Control Panel (You can do this by opening File Explorer and in the path type 'Control Panel' (without quotes) and hit Enter);

  1. From the Control Panel, click on 'Clock and Region'.

  2. Click Region. A new screen will open.

  3. In the screen that opened, click on Administrative and search for the button "Change system location".

  4. Check the option: "Beta: Use Unicode UTF-8 for world language support"

  5. Restart the computer.

Posted on behalf of the question asker

Sign up to request clarification or add additional context in comments.

3 Comments

problem fixed with this solution! Thanks
OMG, after years of not being able to code C on Visual, i finally have a hello world! thank u. Why did this work btw?
This is because the cpp file is inside a folder called "Chuyên Tin", which is not parsed really well in some tools such as GCC. When the compiler receives the path, the accented characters (ê, ư) may be encoded differently depending on the system’s locale or terminal. As a result, GCC cannot correctly resolve the path and throws errors like "No such file or directory".
1

the problem was with Launch.json

the path files should not have any spaces like in my case "prog files" was error and i replaced and rename folder with "progfiles"

"program": "D:\\Progfiles\\vscode\\hello.exe",
"args": [],
"stopAtEntry": false,
"cwd": "D:\\Progfiles\\vscode",
"environment": [],

2 Comments

I had this issue as well, where I had a space in my folder name for my directory. This solution fixed my issue.
You can also use a back slash before spaces to escape them.
0

I had the same error on a Hungarian Windows 10 Virtual Machine, which uses 1250 code page (single byte character set) for representing path strings. I turned on the UTF-8 support as Dharman suggested in https://stackoverflow.com/a/70788314/22377195 but it did not help. The gdb still did not found the executable. My path contained not only spaces but special Hungarian accented characters, like "C:\Users\Cpp Felhasználó\Documents\VS Code\ ...". What finally helped is to remove accented characters from the path, "C:\Users\Cpp Felhasznalo\Documents\VS Code\ ..." - remove accents. I put this new folder under the authority of "Cpp Felhasználó" user too. I copied the files to this accent free folder, and VS Code now works well. What follows from that is spaces are accepted, but special chars must be encoded in UTF-8 if they occure in the paths.

Comments

0

I had the same issue with a long address. Specially because I had it in gdrive in local and some folders are freakin cripted. So I send it to a local partition and I solved it.

1 Comment

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.