我正在尝试将VScode设置为能够使用代码运行程序包来运行C和C++代码的“代码运行程序”包,但它总是会出现以下错误:
[Running] cd "d:\Desktop\Programming\For_fun\tester\" && g++ practice.cpp -o practice && "d:\Desktop\Programming\For_fun\tester\"practice
[Done] exited with code=1 in 0.123 seconds
我发现用wsl和ubuntu编译和运行就行了,但是普通的命令提示符就不行了,我想这是一个很大的问题是什么,但我不知道如何解决它,甚至不知道如何开始搜索。
我使用的是Windows 10
这是我的代码:
#include <vector>
#include <iostream>
#include <string>
using namespace std;
int main() {
cout << "Hello World!\n";
return 0;
}
以下是我尝试确认是否安装了相关软件包的结果:
PS D:\Desktop\Programming\For_fun\tester> c++ --version
c++.exe (MinGW.org GCC Build-20200227-1) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
PS D:\Desktop\Programming\For_fun\tester> gcc --version
gcc.exe (Rev5, Built by MSYS2 project) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
PS D:\Desktop\Programming\For_fun\tester> g++ --version
g++.exe (MinGW.org GCC Build-20200227-1) 9.2.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
谢谢!
发布于 2021-08-04 06:19:01
它不起作用。但我解决了这个问题:基本上,我使用windows finder查找gcc.exe的所有实例,并删除了我的程序文件中包含它们的文件夹。然后,我从我的环境变量中删除了它们的路径。最后,我通过cygwin干净利落地重装了gcc核心和gcc-g++,并且工作了。
https://stackoverflow.com/questions/68607944
复制相似问题