将Scala库转换为DLL(.NET) [英] Converting a Scala library to a DLL (.NET)

查看:198
本文介绍了将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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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