Tasks.json不接受多个文件的通配符



我有一个文件夹,里面有多个cpp文件,我想用g++(MinGW(将它们编译成DLL。

我的Tasks.json看起来像这样:

{
// 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
}
}
]

}

当我执行其中一个任务时,它只是试图编译一个名为*.cpp的文件,或者试图链接一个名称为*.o的文件,这当然是错误的。

> Executing task: D:ProgrammeMinGWbing++ -c 'D:...PluginsPluginDev*.cpp' '-ID:...PluginsPluginDev....sdkinclude' <
g++.exe: error: D:...PluginsPluginDev*.cpp: Invalid argument

我该如何解决这个问题?

我发现用*.cpp替换${workspaceFolder}\*.cpp在添加选项并更改cwd:后有效

"args": [...],
"options": {
"cwd": "${fileDirname}"
}

最新更新