【发布时间】:2020-03-24 03:13:39
【问题描述】:
我已经测试过使用 WSL 在 vscode 上对多个文件进行编码
code .
在好文件夹中。
我有三个文件。
这是我得到的错误信息,而代码是正确的:
g++:错误:helloworld.cpp:没有这样的文件或目录
g++:错误:file2.cpp:没有这样的文件或目录 g++:错误:file3.cpp:没有这样的文件或目录
g++:致命错误:没有输入文件
编译终止。
终端进程以退出代码终止:1
终端将被任务重用,按任意键关闭它。
这是我的 tasks.json 文件:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": [
"-g",
"helloworld.cpp","file2.cpp","file3.cpp",
"-o",
"executable.out"
],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
请您帮忙解决这个问题,而这里提到的单个文件非常有效:
https://code.visualstudio.com/docs/cpp/config-wsl#_modifying-tasksjson
我还指出 .cpp 文件不在 .vscode 文件夹中,而是在项目的主文件夹中。 提前致谢
ps:我看到了几个关于这个问题的帖子,但这并没有解决我的问题。
【问题讨论】:
-
如果你在终端运行你想要的目录下的构建命令,输出是什么?
-
我在终端手动测试,做 g++ -g helloworld.cpp file2.cpp -o fileexec ,它编译。但我的问题是不同的,你可以看到
标签: c++ visual-studio-code windows-subsystem-for-linux