I just started to setup my VS Code in WSL. I followed by the instruction from GCC on Windows subsystem for Linux . Most of the work is done, there is only one issue. For this part:
Modifying tasks.json
You can modify your tasks.json to build multiple C++ files by using an argument like
${workspaceFolder}/*.cpp
instead of${file}
. You can also modify the output filename by replacing${fileDirname}/${fileBasenameNoExtension}
with a hard-coded filename (for example 'helloworld.out').
I want to compile multiple cpp files, but the method provides from above ${workspaceFolder}/*.cpp
instead of ${file}
doesn't work for me. After I replaced it, the g++ seems like recognize the *.cpp as a file so it can't find it.
This is what the terminal shows.
g++: error: /.../.../*.cpp: No such file or directory
g++: fatal error: no input files
compilation terminated.
The terminal process terminated with exit code: 1
Try this instead: "${workspaceFolder}/**.cpp"
From the website you posted the example tasks.json
would be this
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "g++ build active file",
"command": "/usr/bin/g++",
"args": ["-g", "${workspaceFolder}/**.cpp", "-o", "${fileDirname}/${fileBasenameNoExtension}"],
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
I can't tell you the reasoning behind the double asterix * but it takes all the files with.cpp ending in the current folder.
I find out the problem is on the name of my folder. There is a space in my folder name, so change the name of the folder solved this problem. It is really not a good habit to use space. But if you continue to want to use a name that contains space, do "\"${workspaceFolder}\"/ .cpp" instead of "${workspaceFolder}/ .cpp" .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.