![](/img/trans.png)
[英]'g++' is not recognized as an internal or external command, operable program or batch file
[英]VScode Terminal giving output: 'g++' is not recognized as an internal or external command, operable program or batch file
我首先從https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/安裝了 Mingw 並下載了所有軟件包並將 C:\\MinGW\\bin 設置為我的環境中的新路徑系統變量。 我打開我的命令提示符並輸入“g++ --version”,它給了我輸出“g++(MinGW.org GCC-8.2.0-5)8.2.0”所以我相信這意味着到目前為止我遵循正確的路徑.
當我在 VSCode 中嘗試編譯基本的 hello world 文件時出現了我的問題。 在終端中,我輸入了“g++ main.cpp”,但是這讓我得到了輸出“'g++' 不是內部或外部命令,也不是可運行的程序或批處理文件。” 這與我的 .json 文件之一的設置方式有關嗎? 我已經包含了以下 c_cpp_poperties、啟動和任務代碼。
謝謝你。
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4}
啟動.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "C++ Compiler",
"type": "cppvsdbg",
"request": "launch",
"program": "C:/MinGW/bin",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true
},
]}
任務.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "C:/MinGW/bin/g++",
"args": [
"-g",
"-o",
"helloworld",
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]}
代替
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
和
"compilerPath": "C:\\MinGW\\bin\\g++.exe",
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.