无法构建 gem —— 本机扩展构建失败 —— 你能明白为什么吗?

发布于 2024-07-29 20:22:12 字数 3912 浏览 5 评论 0 原文

我不明白这里出了什么问题——有什么想法吗?

我在 Ubuntu 8.04 LTS 上运行,并按照以下说明安装了 libxml2 和 libxslt:

http://www.techsww.com/tutorials/libraries/libxml/installation/installing_libxml_on_ubuntu_linux.php

http://www.techsww.com/tutorials/libraries/libxslt/installation/installing_libxslt_on_ubuntu_linux.php

但是,我安装了最新版本:

libxslt-1.1.24
libxml2-2.7.3

安装很顺利

--------------------我设置了LD_LIBRARY_PATH ----------- -----------------------

echo $LD_LIBRARY_PATH
/usr/local/libxslt/lib:

------------- 似乎该函数存在 - 至少基于字符串的输出 ------------
/usr/local/libxslt/lib$ 字符串 * | grep ParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc

----------------------- 但编译仍然失败-------------------- -------------------

sudo gem install webrat
构建本机扩展。 这可能需要一段时间...
错误:安装 webrat 时出错:
错误:无法构建 gem 本机扩展。

/usr/local/bin/ruby extconf.rb 安装 webrat
检查 /opt/local/include/、/opt/local/include/libxml2、/opt/local/include、/opt/local/include、/opt/local/include/libxml2、/usr/local 中的 iconv.h /include、/usr/local/include/libxml2、/usr/local/include、/usr/local/include/libxml2、/usr/include、/usr/include/libxml2... 是
检查 /opt/local/include/、/opt/local/include/libxml2、/opt/local/include、/opt/local/include、/opt/local/include/libxml2、/usr 中的 libxml/parser.h /local/include、/usr/local/include/libxml2、/usr/local/include、/usr/local/include/libxml2、/usr/include、/usr/include/libxml2... 是
检查 /opt/local/include/、/opt/local/include/libxml2、/opt/local/include、/opt/local/include、/opt/local/include/libxml2、/usr 中的 libxslt/xslt.h /local/include、/usr/local/include/libxml2、/usr/local/include、/usr/local/include/libxml2、/usr/include、/usr/include/libxml2... 是
检查 /opt/local/include/、/opt/local/include/libxml2、/opt/local/include、/opt/local/include、/opt/local/include/libxml2、/usr 中的 libexslt/exslt.h /local/include、/usr/local/include/libxml2、/usr/local/include、/usr/local/include/libxml2、/usr/include、/usr/include/libxml2... 是
检查 -lxml2 中的 xmlParseDoc()...是
检查 -lxslt 中的 xsltParseStylesheetDoc()... 否
libxslt 丢失。 尝试“port install libxslt”或“yum install libxslt-devel”
*** extconf.rb 失败 ***
由于某种原因无法创建 Makefile,可能缺少
必要的库和/或标头。 检查 mkmf.log 文件了解更多信息
细节。 您可能需要配置选项。

提供的配置选项:
--with-opt-dir
--没有选择目录
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--没有make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-iconv-dir
--没有 iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-xml2lib
--没有-xml2lib
--with-xsltlib
--without-xsltlib

Gem 文件将保留安装在 /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.3.3 中以供检查。
结果记录到 /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.3.3/ext/nokogiri/gem_make.out

I can't figure out what is going wrong here -- any ideas??

I'm running on a Ubuntu 8.04 LTS, and have installed libxml2 and libxslt from these instructions:

http://www.techsww.com/tutorials/libraries/libxml/installation/installing_libxml_on_ubuntu_linux.php

http://www.techsww.com/tutorials/libraries/libxslt/installation/installing_libxslt_on_ubuntu_linux.php

However, I installed the latest versions:

libxslt-1.1.24
libxml2-2.7.3

The install was uneventful

-------------------- I set LD_LIBRARY_PATH ----------------------------------

echo $LD_LIBRARY_PATH
/usr/local/libxslt/lib:

------------- seems like the function is present -- at least based on the output of strings ------------
/usr/local/libxslt/lib$ strings * | grep ParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc
xsltParseStylesheetDoc

----------------------- But the compile still fails ----------------------------------------

sudo gem install webrat
Building native extensions. This could take a while...
ERROR: Error installing webrat:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb install webrat
checking for iconv.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxml/parser.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libxslt/xslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for libexslt/exslt.h in /opt/local/include/,/opt/local/include/libxml2,/opt/local/include,/opt/local/include,/opt/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/local/include,/usr/local/include/libxml2,/usr/include,/usr/include/libxml2... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... no
libxslt is missing. try 'port install libxslt' or 'yum install libxslt-devel'
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/local/bin/ruby
--with-iconv-dir
--without-iconv-dir
--with-iconv-include
--without-iconv-include=${iconv-dir}/include
--with-iconv-lib
--without-iconv-lib=${iconv-dir}/lib
--with-xml2-dir
--without-xml2-dir
--with-xml2-include
--without-xml2-include=${xml2-dir}/include
--with-xml2-lib
--without-xml2-lib=${xml2-dir}/lib
--with-xslt-dir
--without-xslt-dir
--with-xslt-include
--without-xslt-include=${xslt-dir}/include
--with-xslt-lib
--without-xslt-lib=${xslt-dir}/lib
--with-xml2lib
--without-xml2lib
--with-xsltlib
--without-xsltlib

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.3.3 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/nokogiri-1.3.3/ext/nokogiri/gem_make.out

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

亚希 2024-08-05 20:22:12

尝试安装到非标准位置时出现相同的错误(因为我无权访问主目录之外的目录)。 似乎这个答案只是简单地安装到 /usr 中的默认位置即可成功。 还是我理解错了?

有关我正在尝试执行的操作的更多背景信息,请访问 http://groups .google.com/group/nokogiri-talk/browse_thread/thread/c1e909be09e90f5a,如果有帮助的话。

I get the same error when trying to install to a non-standard location (as I don't have access to directories outside my home directory). It seems as if this answer simply installed to the default location in /usr for success. Or did I misunderstand?

More context about what I'm trying to do at http://groups.google.com/group/nokogiri-talk/browse_thread/thread/c1e909be09e90f5a, if that's helpful.

一江春梦 2024-08-05 20:22:12

尝试删除 libxslt* 并重新安装它们。 这为我解决了这个问题。

Try removing the libxslt* and install them again. That fixed the issue for me.

世界和平 2024-08-05 20:22:12

您必须安装这些库的开发套件。

You have to install the development kits of these libraries.

甚是思念 2024-08-05 20:22:12

在 Ubuntu 中,您需要执行以下步骤:
sudo apt-get install libxml2-dev
sudo apt-get install libxslt-dev

In Ubuntu you need to follow these steps:
sudo apt-get install libxml2-dev
sudo apt-get install libxslt-dev

黒涩兲箜 2024-08-05 20:22:12

Jared Evans 在他的博客这篇文章中描述了一个在 Ubuntu 8.04 上对我有用的解决方案LTS。 他的技巧是不使用 apt-get 来安装 ruby​​gems,而是从源代码构建它。 这对我来说非常有用。 他的帖子是针对安装 rails 的,因此我使用了以下(稍作修改的)步骤来安装 nokogiri:

首先使用 APT-GET 安装 RUBY:

 sudo apt-get update
 sudo apt-get install ruby irb ri rdoc ruby1.8-dev libzlib-ruby
  libyaml-ruby libreadline-ruby libncurses-ruby libcurses-ruby libruby
  libruby-extras libfcgi-ruby1.8 build-essential libopenssl-ruby
  libdbm-ruby libdbi-ruby libdbd-sqlite3-ruby sqlite3 libsqlite3-dev
  libsqlite3-ruby libxml-ruby libxml2-dev

除了 JARED'S我还安装了说明(我不确定 libxslt1.1 是否必要):

 sudo apt-get install libxslt1.1
 sudo apt-get install libxslt1-dev

下载 RUBYGEMS 源:

下载 来自 ruby​​forge 的最新 RubyGems (当前为 1.3.6)(我使用了 zip 包)。

构建 RUBYGEMS:

 cd /TO/DIRECTORY/WHERE/YOU/UNZIPPED/rubygems-1.3.6/
 sudo ruby setup.rb
 sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

安装 NOKOGIRI:

 sudo gem update –system
 sudo gem install nokogiri

响应将是:

1 gem installed
Installing ri documentation for nokogiri-1.4.1...

No definition for parse_memory

No definition for parse_file

No definition for parse_with

No definition for get_options

No definition for set_options
Installing RDoc documentation for nokogiri-1.4.1...

No definition for parse_memory

No definition for parse_file

No definition for parse_with

No definition for get_options

No definition for set_options

我还没有注意到“无定义”消息引起的任何问题...

Jared Evans in this post on his blog, described a solution that worked for me on Ubuntu 8.04 LTS. His trick is to NOT use apt-get to install rubygems, but rather to build it from source. This worked great for me. His post is directed at installing rails, so I used these (modified slightly) steps from it to just install nokogiri:

FIRST INSTALL RUBY WITH APT-GET:

 sudo apt-get update
 sudo apt-get install ruby irb ri rdoc ruby1.8-dev libzlib-ruby
  libyaml-ruby libreadline-ruby libncurses-ruby libcurses-ruby libruby
  libruby-extras libfcgi-ruby1.8 build-essential libopenssl-ruby
  libdbm-ruby libdbi-ruby libdbd-sqlite3-ruby sqlite3 libsqlite3-dev
  libsqlite3-ruby libxml-ruby libxml2-dev

IN ADDITION TO JARED'S INSTRUCTIONS I ALSO INSTALLED (I'm not certain that libxslt1.1 is necessary):

 sudo apt-get install libxslt1.1
 sudo apt-get install libxslt1-dev

DOWNLOAD RUBYGEMS SOURCE:

Download the latest RubyGems (currently 1.3.6) from rubyforge (I used the zip package).

BUILD RUBYGEMS:

 cd /TO/DIRECTORY/WHERE/YOU/UNZIPPED/rubygems-1.3.6/
 sudo ruby setup.rb
 sudo ln -s /usr/bin/gem1.8 /usr/bin/gem

INSTALL NOKOGIRI:

 sudo gem update –system
 sudo gem install nokogiri

The response will be:

1 gem installed
Installing ri documentation for nokogiri-1.4.1...

No definition for parse_memory

No definition for parse_file

No definition for parse_with

No definition for get_options

No definition for set_options
Installing RDoc documentation for nokogiri-1.4.1...

No definition for parse_memory

No definition for parse_file

No definition for parse_with

No definition for get_options

No definition for set_options

I haven't yet noticed any problems caused by the 'No definition' messages...

岛歌少女 2024-08-05 20:22:12

这是在 Ubuntu 11.04 (natty) 上对我有用的方法:

sudo apt-get install libxslt-dev libxml2-dev

sudo gem install nokogiri

Here's what worked for me on Ubuntu 11.04 (natty):

sudo apt-get install libxslt-dev libxml2-dev

sudo gem install nokogiri

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文