How can I pass arguments to GCC when it is compiling. My old automake is passing the compiler argument -fPIC.
I have searched everywhere and none of the suggestions have worked.
toolChains {
gcc(Gcc) {
linker.withArguments { List<String> args ->
args << "-fPIC"
}
}
}
Exception thrown while executing model rule: model.toolChains
Could not find property ‘linker’ on Tool chain ‘gcc’ (GNU GCC).
libraries {
myLib {}
all {
binaries.all {
cppCompiler.args "-fPIC"
linker.args "-fPIC"
}
}
}
Build works fine, but I cannot see any gcc command being fired with the arguments.
toolChains {
gcc(Gcc) {}
target("x64") {
cppCompiler.withArguments { args ->
args << "-fPIC"
}
}
}
Exception thrown while executing model rule: model.toolChains
Could not find method target() for arguments [x64, build_1rpm5hj0c7lgodlywh65wn8if$_run_closure1_closure4_closure7@38ed139b] on NativeToolChain container.
toolChains {
gcc(Gcc) {
cppCompiler.withArguments { args ->
args << "-fPIC"
}
}
}
Exception thrown while executing model rule: model.toolChains
Could not find property ‘cppCompiler’ on Tool chain ‘gcc’ (GNU GCC).
toolChains {
gcc(Gcc) {
cppCompiler.args '-fPIC'
}
}
Edit: In an obscure corner of the Internet I found something that works. At least gradle build is successful.
model {
platforms {
x64 {
architecture "x86_64"
operatingSystem "linux"
}
}
toolChains {
gcc(Gcc) {
cppCompiler.withArguments { args ->
args.add("-fPIC")
}
}
}
}
On a second thougth: It seems args.add(“-ARG”) works just as args << “-ARG”, but only on Gradle 2.1. Using Gradle 2.2.1 and the latest 2.4-nightly I get the following error: > Exception thrown while executing model rule: model.toolChains
Could not find property ‘cppCompiler’ on Tool chain ‘gcc’ (GNU GCC).