windowsvisual-studio-codelinker

VSCode C++ on Windows. How to specify linker options?


For a basic command line windows C++ application, the tasks.json file contains the compiler command:

{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe build active file",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/nologo",
                "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
                "${file}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

How does one specify options to the linker? I need to specify the /SAFESEH option so that my McAfee doesn't quarantine my executable every time that I build.

Thanks in advance.

I tried adding that linker option to the cl.exe command arguments but that fails due to cl.exe being a compiler command, not a link command.


Solution

  • usage: cl [ option... ] filename... [ /link linkoption... ]

    Looks like you would need to add to the cl args area:

    "/link SAFESEH",