Piasy
Piasy

Reputation: 1009

Kotlin Native cinterop def file: how to eliminate absolute path?

When specify linkerOpts, we need set absolute path for -L option, but it's easy to break.

In older version, setting linkerOpts in build.gradle could work, but in 1.3.50, it warns that "-linker-option(s)/-linkerOpts/-lopt option is not supported by cinterop. Please add linker options to .def file or binary compilation instead.", and build do fail with "Undefined symbols" error.

What could I do?

Upvotes: 1

Views: 1574

Answers (1)

Artyom Degtyarev
Artyom Degtyarev

Reputation: 2888

This option is going to be deprecated once, so the warning was intentionally added after the 1.3.50 release. The motivation here is that one should prefer to set all linker options, even platform-specific, via .def file.
But, the build should not break apart in this case. Can you add the script contents, to make it clearer - what exactly led to the error?


UPD: After the GH project was shared in the comments I want to add some details here. This problem is described in the documentation here, this part:

Often it's necessary to specify target-specific linker options for a binary which uses a native library. It can be done using the linkerOpts property of the binary.

So, in this particular case, it will be correct to add the option to the binaries section instead of the cinterops. In the end, I made things together with

binaries {
    all {
        linkerOpts = ['-L'+rootProject.projectDir+'/libs/NativeBase64/iOS/', '-lNativeBase64']
    }
}

Upvotes: 3

Related Questions