将Scala库转换为DLL(.NET)

编程入门 行业动态 更新时间:2024-10-20 16:30:56
本文介绍了将Scala库转换为DLL(.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在尝试从scala类中创建一个Dll。我正在使用IntelliJ和SBT。我已经找到了一种使用ikvm转换器将.jar文件转换为Dll的方法。现在的问题:当我使用SBT下的软件包从.scala文件创建一个.jar文件,并尝试将其转换为ikvmc到Dll中,当集成到C#中时,生成的库为空...

例如,转换Jama-Library(以Java编写)可以正常工作,转换Scama(以Scala编写)不起作用。

有没有办法将scala代码转换成d​​ll?有没有Scala to Java转换工具?

最好的问候, Christoph

解决方案

我不了解.NET,但从SK-logic和您的意见来判断问题: sbt package does 不包括Scala运行时库,因为它假定您要将项目导出为要在其他Scala项目中使用的库。

因此,您将需要创建一个包含运行时的胖jar。例如,在此博客您可以通过转换项目jar和运行时jar来了解作者如何创建完全独立的可执行文件。

有不同的工具可以做到这一点SBT。最简单的是 sbt-assembly ,但是最终会出现一个非常大的文件,因为它只是添加了整个运行时。如果这是一个问题,您可能需要使用 proguard插件。有关此主题的更多信息,请参阅另一个StackOverflow条目。

I'm trying to create a Dll out of a scala-class. I'm using IntelliJ together with SBT. I've already found a way to convert .jar files into a Dll, using the ikvm-converter. Now the problem: When I use "package" under SBT to create a .jar file out of my .scala file and try to convert it afterwards with ikvmc into a Dll the resulting library is empty when integrated in C#...

For example converting the Jama-Library (which is written in Java) works fine, where converting Scama (written in Scala) does not work.

Is there a way to do this conversion of scala code into a dll? Is there a "Scala to Java"-conversion tool?

Best Regards, Christoph

解决方案

I have no knowledge of .NET, but judging from SK-logic's and your comments to the questions: sbt package does not include the Scala runtime library, because it assumes you are going to export your project as a library to be used within other Scala projects.

Therefore, you will need to create a "fat" jar that contains the runtime. For example, in this blog you can see how the author creates a fully self-contained executable, by converting both the project jar and the runtime jar.

There are different tools to do that with sbt. The easiest would be sbt-assembly, but you will end up with a very large file, because it just adds the whole runtime. If that is a problem, you may want to filter the runtime instead, using the proguard plugin. More on this topic in another StackOverflow entry.

更多推荐

将Scala库转换为DLL(.NET)

本文发布于:2023-11-17 07:14:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609268.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:转换为   Scala   NET   DLL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!