Need Gradle [2.4-rc-2] to link with gcc and not g++

This was answered in Old Forum but the solution does not work anymore. Everything is compiled using gcc except the linking of my executable with two static libraries, I’m using

apply plugin: ‘c’

so toolChain in Gcc I tried the following but nothing changed (no surprise I guess)

toolChains {
    gcc(Gcc) {
        eachPlatform { tools ->
            tools.cCompiler.executable = "gcc"
        }
    }
}

Can I set something like tools.cCompiler.linker? (Tried that didn’t work)

For reference, the old solution was linker.executable = ‘gcc’

Thank you

I just figured it out, the Groovy way (please comment if there’s a better way or other issue with this)


eachPlatform { tools ->
tools.getLinker().setExecutable(“gcc”)

The “Groovy” way would technically be tools.linker.executable = 'gcc' and should work just as well.

Yes, it does, I just tried it, and of course, use the properties and the getter/setter will be called for you. I was just going by API in the groovy doc I found browsing the native classes, too excited to think of that.

Thank you!