1

I have a static library that needs to link to other static libraries.

When I attempt to run ./gradlew common:cinteropSomeLibIos :

I always get IllegalStateException: Could not find 'libabseil.a' binary in neither of [external/lib]

my def file:

headers = SomeHeader.h
language = Objective-C
package = com.mypackage
staticLibraries = libabseil.a libMyLib.a
libraryPaths = external/lib
linkerOpts = -lObjC -all_load

Everything works within AndroidStudio/IntelliJ but when using the command line interface or building with bazel i consistently get the above error.

I tried adding:

val main by compilations.getting {
        kotlinOptions {
            freeCompilerArgs = listOf(
                "-include-binary", "$libLocation/libabseil.a"
            )
        }
    }

as well as setting linkerOpts within the gradle file but that results in:

warning: -linker-option(s)/-linkerOpts option is not supported by cinterop. Please add linker options to .def file or binary compilation instead.

Is there any way to get this working or at least to call the cinterop task in a way that the relative paths in the .def file will work?

Maurycy
  • 3,911
  • 8
  • 36
  • 44
  • Hello. Can you clarify a bit, you're trying to get rid of the Gradle script and call cinterop tool directly or you just want to make things work with a static library pointed using relative path? – Artyom Degtyarev Jul 13 '20 at 11:04
  • static library + relative path was the original goal (not calling cinterop tool directly). on iOS we are building via Bazel and calling the gradle packForXcode task from bazel (i know) and the relative paths all fail when doing so. – Maurycy Jul 27 '20 at 19:36
  • I solved this by compiling a framework with bazel ios rules that packages the static libraries. And then just add the compiler option to link the framework within the build.gradle.kts file. Was hoping there would be a cleaner / more obvious way – Maurycy Jul 27 '20 at 19:37

0 Answers0