Getting "unrecognized option '-Wl,-soname," when linking native library

Hello,

I’m new to Gradle and using gradle 2.1

I am cross compiling for arm using a CodeSourcery compiler. The compile step works and I can create a static library.

I am getting this error when trying to link a native (C++) shared library.

:compileReleaseIrapSharedLibraryIrapCpp UP-TO-DATE :linkReleaseIrapSharedLibrary /path/to/CodeSourcery/bin/arm-xilinx-linux-gnueabi-ld: unrecognized option ‘-Wl,-soname,libirap.so’ /path/to/CodeSourcery/bin/arm-xilinx-linux-gnueabi-ld: use the --help option for usage information :linkReleaseIrapSharedLibrary FAILED

Those appear to be default options that I have not specified. In the docs, it looks like I should be able to remove those options using args.remove. Below is my latest toolchain configuration and attempt to remove the “-Wl” flag. Thanks in advance for any ideas how to get past this.

model {
    buildTypes {
        debug
        release
    }
    toolChains {
      codesourcery(Gcc) {
        path "/path/to/CodeSourcery/bin"
        cCompiler.executable = 'arm-xilinx-linux-gnueabi-gcc'
        cppCompiler.executable = 'arm-xilinx-linux-gnueabi-gcc'
        linker.executable = 'arm-xilinx-linux-gnueabi-ld'
        assembler.executable = 'arm-xilinx-linux-gnueabi-as'
        staticLibArchiver.executable = 'arm-xilinx-linux-gnueabi-ar'
          linker.withArguments { args ->
          args.remove "-Wl"
        }
      }
    }
}

I got this to work by using

linker.withArguments { args ->

args.remove “-Wl,-soname,libirap.so

}

What I discovered was the options are listed in

build/options and those options are a single complete line in the file. I had to match the complete line for it to be removed.

Ok, this is a better solution. I guess the problem is that the format that the flags are being sent is correct if you are using the compiler for linking, but not right if you are calling the linker (ld) directly. I updated my toolchain configuration to use gcc as the linker instead of ld and that error went away.

armXilinxLinuxGnueabiGcc(Gcc) {
      target("mytarget"){
        // Uncomment to use a GCC install that is not in the PATH
        path "/opt/CodeSourcery/bin"
        cCompiler.executable = 'arm-xilinx-linux-gnueabi-gcc'
        cppCompiler.executable = 'arm-xilinx-linux-gnueabi-gcc'
        linker.executable = 'arm-xilinx-linux-gnueabi-gcc'
        assembler.executable = 'arm-xilinx-linux-gnueabi-as'
        staticLibArchiver.executable = 'arm-xilinx-linux-gnueabi-ar'
      }
    }