g ++任务无法找到简单版本的文件
问题描述:
我正在尝试使用VSL与WSL一起使用。我可以在终端中使用g ++进行编译,但是当我尝试使用任务进行设置时,无法找到源文件。g ++任务无法找到简单版本的文件
为了说明这里的输出,当我尝试一个简单的hello世界C++程序。我已经展示了一个简单的构建任务以及一个ls来显示该文件在那里。这两个任务都是在我将注意力放在源代码文件窗口上时运行的。
Executing task: g++ helloworld.cpp <
>g++: fatal error: no input files compilation terminated.
>Terminal will be reused by tasks, press any key to close it.
>Executing task: ls <
>helloworld.cpp
>Terminal will be reused by tasks, press any key to close it.
我想我必须有一些基本的误解?不用说,当我关闭由任务创建的终端并尝试从命令行构建它时,它就起作用。
testvscpp$ ls
helloworld.cpp
testvscpp$ g++ helloworld.cpp
testvscpp$ ls
a.out helloworld.cpp
任何帮助,将不胜感激。
编辑:构建任务如下。
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Simple build",
"type": "shell",
"command": "g++",
"args": [
"helloworld.cpp"
]
},
{
"taskName": "Show ls",
"type": "shell",
"command": "ls"
}
]
}
这是唯一从documentation找到的版本略有不同 - 不过我也试过这正是它也不能工作。
答
在"args":
,参数-g
要求:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"taskName": "Simple build",
"type": "shell",
"command": "g++",
"args": [
"-g",
"helloworld.cpp"
]
},
{
"taskName": "Show ls",
"type": "shell",
"command": "ls"
}
]
}
对不起,我毫无反应!这对我不起作用。事实上,我发布了VS代码Github,结果发现这个问题与WSL尚未完全支持有关,但是解决方法是添加':'。到任务的参数列表。 https://github.com/Microsoft/vscode/issues/33232 –