How do I specify linker arguments with spaces, single and double quotes?

(Christo Zietsman) #1

I’m trying to set a linker flag for VisualCpp which gradle escaped with quotes:

apply plugin: 'cpp-lib'
libraries {
    main {
        binaries.all {
            if (toolChain in VisualCpp) {
                linkerArgs <funny arg>

The funny arg is: linkerArgs ‘/MANIFESTUAC:“level=‘asInvoker’ uiAccess=‘false’”’ or see for the full text.

This end up in the compiler-options.txt as: “/MANIFESTUAC:“level=‘asInvoker’ uiAccess=‘false’”” and causes the linker to fail.

How to define C++ macro with value?

What exactly do you want to be passed on the command line to link.exe? What would be the correct value in the link.exe options file?

(Christo Zietsman) #3

I think the correct value would be:

/MANIFESTUAC:“level=‘asInvoker’ uiAccess=‘false’”

The problem is that gradle adds quotes around it which confuses the linker.

(Christo Zietsman) #4

I’m going over what Visual Studio says it is passing on the command line to the linker. Thought I would try and keep the difference between what gradle passes to the linker and what Visual Studio pass to a minimum.


Sorry for the delay getting back to you. I don’t think there’s a workaround at present. I’ve raised GRADLE-2943 to track this issue.


I’ve added support for escaping backslashes and double quotes in user args. Unfortunately this doesn’t quite work for linker args in Visual Studio. You’ll need to supply the argument as:

linker.args "/MANIFESTUAC:level='asInvoker' uiAccess='false'"

Gradle will quote the entire argument, so the internal double quotes are not necessary.