I've tried to use EventMachine etc., with JRuby. I get errors about native extensions. I believe this is due to Java limitations. I think the fact that I am on Windows further complicates the issue. Some clarification would be appreciated. What extensions can/can't be used with JRuby? How can I tell? Thanks.
我试过用JRuby来使用EventMachine等。我收到有关原生扩展的错误。我相信这是由于Java的限制。我认为我在Windows上的事实进一步使问题复杂化。一些澄清将不胜感激。 JRuby可以/不能使用哪些扩展?我该怎么说?谢谢。
2 个解决方案
#1
there is no really easy way to use native extensions in jruby. native extensions are calling c code that cant be called in jruby without implementing it in java. aside from that a few extensions are seeing jruby ports, for example EventMachine that you mentioned.
在jruby中使用本机扩展没有非常简单的方法。本机扩展调用不能在jruby中调用的c代码而不在java中实现它。除此之外,一些扩展程序正在看到jruby端口,例如你提到的EventMachine。
and as far as i know the only way to see if you can use a gem/extension with jruby is to read the docs, try it or read the source
并且据我所知,看看你是否可以使用jruby的gem /扩展的唯一方法是阅读文档,尝试它或阅读源代码
#2
JRuby does not support native extensions, unfortunately, because they depend on specific memory and runtime details specific to the C implementation.
Usually you can find an equivalent library on the JVM that will work well as a replacement...
遗憾的是,JRuby不支持本机扩展,因为它们依赖于特定于C实现的特定内存和运行时详细信息。通常你可以在JVM上找到一个等效的库,它可以很好地替代...
To complete LDomagala's answer, you can also refer to this thread related to the same "native extension" issue
要完成LDomagala的答案,您还可以参考与相同“原生扩展”问题相关的此主题
Some installation script may rely on RUBY_PLATFORM
to determine whether to build the native extensions depending on your OS. If you are on windows it will not build them.
某些安装脚本可能依赖于RUBY_PLATFORM来确定是否根据您的操作系统构建本机扩展。如果你在Windows上,它将无法构建它们。
The other way to avoid native compilation is using the ENV var 'NORUBYEXT
'.
避免本机编译的另一种方法是使用ENV var'NORUBYEXT'。
But that still may involve some tweaking in the ruby installation script...
但这仍然可能涉及ruby安装脚本中的一些调整...
#1
there is no really easy way to use native extensions in jruby. native extensions are calling c code that cant be called in jruby without implementing it in java. aside from that a few extensions are seeing jruby ports, for example EventMachine that you mentioned.
在jruby中使用本机扩展没有非常简单的方法。本机扩展调用不能在jruby中调用的c代码而不在java中实现它。除此之外,一些扩展程序正在看到jruby端口,例如你提到的EventMachine。
and as far as i know the only way to see if you can use a gem/extension with jruby is to read the docs, try it or read the source
并且据我所知,看看你是否可以使用jruby的gem /扩展的唯一方法是阅读文档,尝试它或阅读源代码
#2
JRuby does not support native extensions, unfortunately, because they depend on specific memory and runtime details specific to the C implementation.
Usually you can find an equivalent library on the JVM that will work well as a replacement...
遗憾的是,JRuby不支持本机扩展,因为它们依赖于特定于C实现的特定内存和运行时详细信息。通常你可以在JVM上找到一个等效的库,它可以很好地替代...
To complete LDomagala's answer, you can also refer to this thread related to the same "native extension" issue
要完成LDomagala的答案,您还可以参考与相同“原生扩展”问题相关的此主题
Some installation script may rely on RUBY_PLATFORM
to determine whether to build the native extensions depending on your OS. If you are on windows it will not build them.
某些安装脚本可能依赖于RUBY_PLATFORM来确定是否根据您的操作系统构建本机扩展。如果你在Windows上,它将无法构建它们。
The other way to avoid native compilation is using the ENV var 'NORUBYEXT
'.
避免本机编译的另一种方法是使用ENV var'NORUBYEXT'。
But that still may involve some tweaking in the ruby installation script...
但这仍然可能涉及ruby安装脚本中的一些调整...