vscode-docs icon indicating copy to clipboard operation
vscode-docs copied to clipboard

cpp

Open Raz270 opened this issue 1 year ago • 1 comments

tried to install c/cpp to VS CODE,

followed manuals for downloading compiler ,

edited .vscode\c_cpp_properties.json

{ "configurations": [ { "name": "Win32", "includePath": [ "${workspaceFolder}/**" ], "defines": [ "_DEBUG", "UNICODE", "_UNICODE" ], "windowsSdkVersion": "10.0.22621.0", "compilerPath": "c:\\Program^ Files (x86)\\Microsoft^ Visual^ Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.38.33130\\bin\\Hostx64\\x64\\cl.exe", "cStandard": "c17", "cppStandard": "c++17", "intelliSenseMode": "windows-msvc-x64" } ], "version": 4 }

.vscode\launch.json

{ "version": "0.2.0", "configurations": [ { "name": "C/C++: cl.exe build and debug active file", "type": "cppvsdbg", "request": "launch", "program": "${fileDirname}\\${fileBasenameNoExtension}.exe", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, "preLaunchTask": "C/C++: cl.exe build active file" } ] }

.vscode\tasks.json

{ "version": "2.0.0", "windows": { "options": { "shell": { "executable": "cmd.exe", "args": [ "/C", // The path to VsDevCmd.bat depends on the version of Visual Studio you have installed. "\"C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\Common7\\Tools\\VsDevCmd.bat\"", "&&" ] } } }, "tasks": [ { "type": "shell", "label": "cl.exe build active file", "command": "cmd", "args": [ "/K", "\"C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/Common7/Tools/VsDevCmd.bat\"", "&&", "cl.exe", "/Zi", "/EHsc", "/Fe:${fileDirname}\\${fileBasenameNoExtension}.exe", "${file}" ], "problemMatcher": ["$msCompile"], "group": { "kind": "build", "isDefault": true } } ] }

keep getting when trying to run image

cl.exe build and debug is only usable when VS Code is run from the Developer Command Prompt for VS.

what should I do ?

Raz270 avatar Jan 06 '24 09:01 Raz270

Hi @Raz270, thanks for reaching out.

In order to build and debug, the C++ extension needs certain environment variables on windows. To avoid having to hardcode them, you can just launch from the developer command prompt. Close your current instance of VS Code. Type "Developer Command Prompt" into the search bar of your computer. Then, navigate using the command prompt to the location of the folder you previously had open in vscode. Use the command "code ." to open that folder. Now the play button should work for you. If you want a more detailed step by step guidance, reference the first 3 steps in this section of our docs.

AlexandraKemperMS avatar Jan 08 '24 19:01 AlexandraKemperMS