如何在Windows上使用Jruby的nokogiri? [英] How to use nokogiri from Jruby on Windows?

查看:86
本文介绍了如何在Windows上使用Jruby的nokogiri?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows 7上尝试将Nokogiri与Jruby一起使用时出现以下错误

I'm getting the following error when trying to use Nokogiri with Jruby on Windows 7

D:\code\h4>jruby -e "require 'rubygems'; require 'nokogiri'"
D:/jruby-1.3.1/bin/../lib/ruby/1.8/ffi/library.rb:18:in `ffi_lib': Could not ope
n any of [xml2, xslt, exslt] (LoadError)
        from D:/jruby-1.3.1/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokog
iri/ffi/libxml.rb:5
        from D:/jruby-1.3.1/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokog
iri/ffi/libxml.rb:31:in `require'
        from D:/jruby-1.3.1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_requir
e.rb:31:in `require'
        from D:/jruby-1.3.1/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokog
iri.rb:10
        from D:/jruby-1.3.1/lib/ruby/gems/1.8/gems/nokogiri-1.3.3-java/lib/nokog
iri.rb:36:in `require'
        from D:/jruby-1.3.1/bin/../lib/ruby/site_ruby/1.8/rubygems/custom_requir
e.rb:36:in `require'
        from -e:1

似乎是Jruby的本机扩展(libxml2)不兼容的问题,但是我发现此处的解决方法,但是找不到libexslt.so,并且不确定将其放在何处.有没有人有使用jruby + windows + nokogiri + libexslt的成功经验? TIA

Seems to be a problem with native extensions (libxml2) incompatibility of Jruby, however I've found a workaround here, but couldn't find libexslt.so and am not sure where to put it. Does anyone have a successful experience of using jruby+windows+nokogiri+libexslt? TIA

推荐答案

您找到的解决方法是针对UNIX系统的; .so文件是一个可加载的模块,类似于Windows中的DLL.而且您无法在Windows中进行软链接(ln -s命令),因此这不适用于您的情况.

The workaround you found is for a UNIX system; the .so file is a loadable module, similar to a DLL in Windows. And you can't softlink in Windows (the ln -s command), so that doesn't apply in your situation.

尽管如此,您确实存在相同的问题,因为nokogiri找不到您的 libxml2,libxslt和& libexslt库.由于我不使用JRuby或nokogiri,因此我真的不确定它如何工作,但我最大的猜测是:

Nonetheless, you do have the same problem in that nokogiri can't find your libxml2, libxslt, & libexslt libraries. Since I don't use JRuby or nokogiri, I'm really not sure how it'll work, but my best guess is this:

最有可能,您需要的Windows二进制文件(DLL). libxml2 libxslt ;其他相关的Windows二进制文件可能是必需的,并且可以在同一位置获得.您将需要将DLL安装在路径中的某个位置,或者最好将其安装在与JRuby可执行文件相同的目录中(看起来像"D:/jruby-1.3.1/bin"). (如果那行不通,也许像libxmlj这样的Java原生库形式可能会起作用,但我对此表示怀疑-您可能需要Windows原生的库.)

Most likely, you need Windows binaries (DLLs) of libxml2 and libxslt at a minimum; other related Windows binaries may be needed and are available at the same place. You'll want the DLLs installed somewhere in your path, or better yet in the same directory as your JRuby executable (looks like "D:/jruby-1.3.1/bin"). (If that doesn't work, perhaps a Java-native form of the libraries like libxmlj might work, but I doubt it--you probably need ones native to Windows.)

我希望这会带您上班.

这篇关于如何在Windows上使用Jruby的nokogiri?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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