Vscode-cpptools: How to run the code

Created on 1 Sep 2016  路  4Comments  路  Source: microsoft/vscode-cpptools

Hi CPP team,
thank you so much for your effort. I have issue with the tools, I already installed everything you guys asked, and I still cannot configure out the right json files. Can you tell me what I need to do to make the debugger run in the Code?

What I did is I just create a .cpp file, then I click the debugger icon, but it keeps asking me to configure the launch.json. I have no idea how to do it. Normally I just g++ the file and then ./ the out file, so what I need to do with the visual studio code?

The error is: launch: program 'enter program name, for example /Users/bill....

What I need to replace the workspaceRoot?

my file located here :

Xis-MacBook-Pro:CPP bill$ ls
Hello       Hello.cpp   foo.h
Xis-MacBook-Pro:CPP bill$ pwd
/Users/bill/Documents/Course/pluralsight/CPP

Thank you so much, here is the json file.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "enter program name, for example ${workspaceRoot}/a.out",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceRoot}",
            "environment": [],
            "externalConsole": true,
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "gdb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        },
        {
            "name": "C++ Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "enter program name, for example ${workspaceRoot}/a.out",
            "processId": "${command.pickProcess}",
            "linux": {
                "MIMode": "gdb"
            },
            "osx": {
                "MIMode": "lldb"
            },
            "windows": {
                "MIMode": "gdb"
            }
        }
    ]
}
debugger question

Most helpful comment

@heyAyushh You need to enter the name of the binary that you compiled in the string that has "enter program name".

All 4 comments

Hi @billchenxi,

VsCode does not automatically build your project in the way that Visual Studio does. It is designed as a light-weight editor with some debugging features. It isn't a full IDE.

You will have to either compile your code using the command-line, or you can set up a tasks.json to do the compilation step for you. An example is in our documentation:

http://code.visualstudio.com/docs/languages/cpp

After that, you can set up the "program" component to be the output of your compilation. For example ${workspaceRoot}/a.out

I am getting Same error even after correcting what you said..

screen shot 2017-10-21 at 02 49 06

@heyAyushh You need to enter the name of the binary that you compiled in the string that has "enter program name".

I have the same issue, but i am using it on windows.

Was this page helpful?
0 / 5 - 0 ratings