'No shared library binary available for library' when trying to do an 'api' dependency on a header-only prebuilt library from another project

This is a native (c++) project on Gradle 2.5.

In project B, I have declared a prebuilt, header-only library:

model {
  repositories {
  // define prebuilt libraries so we can depend on them
    libs(PrebuiltLibraries) {
      mcu_kernel_includes {
        headers.srcDir "${sourceDir}/${repoName}/include"
      }
    }
  }
}

In project A, I try to do an ‘api’ dependency on the prebuilt library from projectB:

lib project: ':projectB', library: 'mcu_kernel_includes', linkage: 'api'

and I get the following error.

* What went wrong:
No shared library binary available for library 'mcu_kernel_includes' with [flavor: 'default', platform: 'arm', buildType: 'debug']

There is no binary, because it is currently a header-only prebuilt library. I am not yet building the library in Gradle, and shouldn’t need it for an ‘api’ linkage. I am successfully using header-only prebuilt libraries within ProjectA.

For example if I define the header only prebuilt library in project A like this:

mcu_kernel_includes {
    headers.srcDir '/path/to/mcu_kernel_src/include'
}

and depend on it in projectA like this:

lib library: 'mcu_kernel_includes', linkage: 'api'

it works as expected.

I would expect to be able to define a header-only prebuilt library and do an ‘api’ (header-only) inkage against it from another project.

Thanks

Hi Derek,

I just wanted to acknowledge I am seeing the same; It is also fails with the same if you try to statically link a pre-built library declared in a repository in a separate project. So it would appear to be a symptom of the way it handles repositories.

Did you ever find a work around or solution?

Thanks,
Shaun

Hi Derek,

Quick follow up to say that I resolved this issue (should anyone be attempting to do the same thing, the solution is below).

In your scenario; project B needs to define its buildTypes and/or platforms. Once these were added to the project the library resolves correctly, this works for all linkage types, static, shared and api.

Took a few minutes of debugging to realise where it was going wrong.

Thanks,
Shaun