因此,我一直到处寻找,但我尝试没有任何帮助。这种情况非常独特。我尝试用VSCode编译一个简单的程序,如果给我以下错误:
g++ : The term 'g++' is not recognized as the name of a cmdlet, function,
script file, or operable program.
问题是我对所有内容的设置方式都与笔记本电脑相同,甚至在安装和配置该程序时也遵循了我的指导说明。
我已经安装了MinGW,并将其添加到环境路径,并在task.json中使用了以下代码:
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"main.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
],
"presentation": {
"echo": true,
"reveal": "always",
"focus": true,
"panel": "shared"
}
}
我还尝试在“ tasks.json”文件中添加完整路径,并将MinGW路径也添加到系统变量中。
让我感到困惑的是,即使我检查的笔记本电脑和台式机之间的内容完全相同,我的笔记本电脑也可以正常编译所有内容。两者都运行Windows 10 v 1803,最新更新,都在C:中安装了MinGW,环境变量路径是相同的“ C:\ MinGW \ bin”,并且都使用了相同的“ tasks.json”。
#include <iostream>
using namespace std;
int main(){
cout<< "hello world! " << endl;
cout<< "Hear me roar";
return 0;
}
感谢您的帮助。
P.S g ++ -v有效。忘了说。