Kotlin Native cinterop def文件:如何消除绝对路径? [英] Kotlin Native cinterop def file: how to eliminate absolute path?

查看:257
本文介绍了Kotlin Native cinterop def文件:如何消除绝对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

指定linkerOpts时,我们需要为-L选项设置绝对路径,但很容易中断.

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

在旧版本中,可以在build.gradle中设置linkerOpts,但是在1.3.50中,它警告cinterop不支持"-linker-option(s)/-linkerOpts/-lopt选项.请添加链接器选项改为.def文件或二进制编译.",并且构建过程因未定义符号"错误而失败.

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.

我该怎么办?

推荐答案

此选项将被弃用一次,因此在1.3.50发行版之后有意添加了该警告.这里的动机是人们应该更喜欢设置所有链接器选项,甚至特定于平台的,通过.def文件.
但是,在这种情况下,构建不应分解.您是否可以添加脚本内容以使其更清晰-到底是什么导致了错误?

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:在评论中共享GH项目之后,我想在此处添加一些详细信息. 此处中对此问题进行了描述. ,此部分:

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:

通常,需要为使用本机库的二进制文件指定特定于目标的链接器选项.可以使用二进制文件的linkerOpts属性来完成.

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.

因此,在这种情况下,将选项添加到binaries部分而不是cinterops是正确的.最后,我与

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

这篇关于Kotlin Native cinterop def文件:如何消除绝对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆