Visual Studio Code 找不到我的 MinGW-w64 的 g++ 命令 [英] Visual Studio Code cannot find the g++ command of my MinGW-w64

查看:41
本文介绍了Visual Studio Code 找不到我的 MinGW-w64 的 g++ 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio Code 找不到我的 MinGW 的 g++ 命令(顺便说一句,intelliSense 没有问题,因为我已经正确设置了 c_cpp_propertites.json).任何的想法?在此先感谢,以下是输出:

Visual Studio Code cannot find the g++ command of my MinGW(btw, intelliSense has no problem because I have set c_cpp_propertites.json correctly). Any idea? Thanks in advance, the following is the output:

执行任务:g++ -g helloworld.cpp

Executing task: g++ -g helloworld.cpp

g++ : 术语g++"未被识别为 cmdlet、函数、脚本文件或可运行程序的名称.检查名称的拼写,或者如果包含路径,请验证路径是否正确并重试.

g++ : The term 'g++' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

推荐答案

我遇到了类似的问题,我相信我已经将其范围缩小到因为g++"是你的命令.检查您的任务配置文件并记下您为命令"设置的内容.

I'm having a similar issue and I believe I've narrowed it down to being due to "g++" being your command. Check your task config file and note what you have set for "command".

command"是任务将尝试运行的内容以及您规定的任何参数,在您的情况下我假设是-g"和helloworld.cpp".

"command" is what the task is going to try and run along with whatever arguments you have stipulated which in your case I assume is "-g" and "helloworld.cpp".

现在,我无法确定的是为什么它没有找到 g++,就好像我尝试通过命令提示符编译源文件一样,我没有问题并且编译成功.

Now, what I'm having trouble determining is why it isn't finding g++ as if I try to compile a source file via a command prompt I have no issue and it compiles successfully.

查看 VS 代码的文档,我确实找到了一种在任务配置中引用环境变量的方法:{env:Path} 将作为我的用户环境变量Path"的前缀,它引用了 c:Mingwlibin (注意这是一个准确的路径,只是一个例子).我认为我们已经非常接近让它工作了,这只是通往 g++ 的问题.我的下一次尝试我想我会简单地将命令"更改为引用 g++ 的绝对路径.

Looking through the documentation for VS code I did find a way to reference your environment variables in the task config: {env:Path} will serve as prefix for my User environment variable "Path" which has a reference to c:Mingwlibin (note this is an accurate path, simply an example). I think we're pretty close to getting it to work it's just a matter of pathing to g++. My next attempt I think I will simply change "command" to reference an absolute path to g++.

这篇关于Visual Studio Code 找不到我的 MinGW-w64 的 g++ 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆