'Tasks.json does not accept wildcard for multiple files
I have a folder with multiple cpp files that I want to compile to a DLL with g++ (MinGW).
My Tasks.json looks like this:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Compiler",
"type": "shell",
"command": "D:\\Programme\\MinGW\\bin\\g++",
"args": [
"-c",
"${workspaceFolder}\\*.cpp",
"-I${workspaceFolder}\\..\\..\\sdk\\include"
]
},
{
"label": "Linker",
"type": "shell",
"command": "D:\\Programme\\CodeBlocks\\MinGW\\bin\\g++",
"args": [
"${workspaceFolder}\\**.o",
"-o",
"${workspaceFolder}\\bin\\Plugin.dll",
"-L${workspaceFolder}\\..\\..\\sdk\\lib",
"-lExampleLib",
]
},
{
"label": "Build Plugin",
"dependsOn": [
"Compiler",
"Linker"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
When I execute one of the tasks, it just tries to compile one file named *.cpp
or tries to link one file named *.o
, which is wrong of course.
> Executing task: D:\Programme\MinGW\bin\g++ -c 'D:\...\Plugins\PluginDev\*.cpp' '-ID:\...\Plugins\PluginDev\..\..\sdk\include' <
g++.exe: error: D:\...\Plugins\PluginDev\*.cpp: Invalid argument
How do I fix this?
Solution 1:[1]
I found that replacing ${workspaceFolder}\\*.cpp
with *.cpp
works after adding options and changing cwd:
"args": [...],
"options": {
"cwd": "${fileDirname}"
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Leonardo Alves Machado |