1

I need to pass the arg -Wl,-Bstatic,--whole-archive to g++.

"version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "shell: g++.exe build active file",
            "command": "C:\\MinGW\\x86\\bin\\g++.exe",
            "args": [
                "-g",
                "${file}",
                "-Wl,-Bstatic,--whole-archive",
                "-Xlinker",
                "-Map=${fileDirname}\\${fileBasenameNoExtension}.map",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\MinGW\\x86\\bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        }
    ]
}

It gives me in output this in the terminal.

Executing task: C:\MinGW\x86\bin\g++.exe -g 'c:\Users\remi\Desktop\OK - VSCode\loaderstack.cpp' -Wl,-Bstatic,--whole-archive -Xlinker '-Map=c:\Users\remi\Desktop\OK - VSCode\loaderstack.map' -o 'c:\Users\remi\Desktop\OK - VSCode\loaderstack.exe' <

    At line:1 char:84
    + ... e -g 'c:\Users\remi\Desktop\OK - VSCode\loaderstack.cpp' -Wl,-Bstatic ...
    +                                                                 ~
    Missing argument in parameter list.
    At line:1 char:93
    + ... Users\remi\Desktop\OK - VSCode\loaderstack.cpp' -Wl,-Bstatic,--whole- ...
    +                                                                 ~
    Missing argument in parameter list.
        + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
        + FullyQualifiedErrorId : MissingArgument

Is there anyway to build inside VSCode with these comma-separated args ?

  • show the command VSC executes in the terminal – rioV8 May 28 '20 at 18:50
  • Thank you for reading. Executes added. – MelectronVolt May 28 '20 at 19:07
  • It looks like maybe powershell is getting in the way. What happens if you change the command to & and move the executable to the first argument? – clcto May 28 '20 at 19:23
  • In my trial on my machine the & did not work as expected; it looks like you need to use the `--%` operator as the first argument to get powershell to not try to interpret the line. See https://stackoverflow.com/a/42383116/2721883 and https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_parsing?view=powershell-7: *"The stop-parsing symbol (--%), introduced in PowerShell 3.0, directs PowerShell to refrain from interpreting input as PowerShell commands or expressions."* – clcto May 28 '20 at 19:36
  • Works better... But... now there is a problem with the path. In fact there are spaces and powershell doesn't like them... C:\MinGW\x86\bin\g++.exe --% -g 'c:\Users\remi\Desktop\OK - VSCode\loaderstack.cpp' -o "c:\Users\remi\Desktop\OK - VSCode\loaderstack.exe" g++.exe: error: 'c:\Users\remi\Desktop\OK: Invalid argument – MelectronVolt May 28 '20 at 20:06

0 Answers0