I have two Gradle projects each producing a native static library. I need to link them into one big shared object. The project that does the linking is not expected to have any source files of its own.
I have tried the following:
apply plugin: 'c'
model {
components {
CombinedLibrary(NativeLibrarySpec) {
sources {
c {
lib project: ':one', library: 'one', linkage: 'static'
lib project: ':two', library: 'two', linkage: 'static'
}
}
}
}
}
This causes Gradle to diligently build libraries one and two, but then it just stops. I can make gcc link those properly, if I add these parameters:
-Wl,-whole-archive -lone -ltwo -Wl,-no-whole-archive
I could add all of those parameters manually using linker.args, but Gradle does not go into linking stage at all. It simply stops after building the dependent libraries.