【发布时间】:2021-08-04 07:30:01
【问题描述】:
在 VSCode 中,每当我尝试编译 cpp 文件时,都会收到以下错误:
> Executing task: 'C:\Program Files\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin\g++.exe' -g d:\helloworld\helloworld.cpp -o d:\helloworld\helloworld.exe <
g++.exe: error: d:helloworldhelloworld.cpp: No such file or directory
g++.exe: fatal error: no input files
compilation terminated.
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
tasks.json 文件如下所示:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cpp.exe build active file",
"command": "C:\\Program Files\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\cpp.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
【问题讨论】:
-
您阅读过GCC 的文档吗? VSCode 的?您是否尝试在终端中运行
g++命令?注意你的working current directory ...考虑在你的笔记本电脑上安装一个Linux发行版(例如Ubuntu ...)。 -
我查看了 VSCode 教程,但没有帮助。关于安装 ubuntu,我不认为这是一个与 windows 相关的问题
-
但是你读过documentation of GCC 吗?如果您花几个小时阅读该文档,您会发生什么? MinGW 也有一些文档......
-
您是否尝试过使用正斜杠,例如将
d:\helloworld\helloworld.cpp替换为d:/helloworld/helloworld.cpp? -
@BasileStarynkevitch 非常感谢。阅读 GCC 文档确实很有帮助。
标签: c++ visual-studio-code compiler-errors g++