How can I build a native library without source?


(Jared Buletza) #1

We have a project that builds a dozen static (linux) native libraries. I would like to combine them into a single static library, without adding any additional source compilation.

ex: (projectALib and projectBLib are projects in the same gradle file)

sources {
    // projectALib and projectBLib sources are listed here too...
    combined {
     cpp {
       lib library: 'projectALib', linkage: static
       lib library: 'projectBLib', linkage: static
     }
  }
}
  libraries {
  projectALib {}
  projectBLib {}
  combined {}
}

but when I execute:

gradle combinedStaticLibrary

I get:

:createCombinedStaticLibrary UP-TO-DATE
:combinedStaticLibrary UP-TO-DATE

Previously, with Makefiles, we were accomplishing this with the “ar” command. Obviously I can call to the commandline line and run “ar”, but it seems like Gradle should have a cleaner solution for this.


(Jared Buletza) #2

So, responding to my own post since there was no response.

For me, I was compiling projectALib and ProjectBLib, so I just compile them straight to the “combined” now.

I think that with .a files… there isn’t really a reason to just compile to .a files to one. You would normally just link both of them in another project if you needed to…

So… if you run into problem… I think the thing to do is ask yourself if it is actually necessary in the first place.