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

ⅰ亾dé卋堺 提交于 2019-12-11 14:41:51

问题


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?


回答1:


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']
    }
}


来源:https://stackoverflow.com/questions/58919144/kotlin-native-cinterop-def-file-how-to-eliminate-absolute-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!