在linux mint上的ruby 1.8.7中安装libxml

时间:2013-04-06 14:06:25

标签: ruby gem mint libxml-ruby

这是尝试安装时的结果 - > extconf失败:需要libm

virtualrails@jay ~ $ sudo gem install libxml-ruby
Building native extensions.  This could take a while...
ERROR:  Error installing libxml-ruby:
    ERROR: Failed to build gem native extension.

/opt/rubystack-2.0-0/ruby/bin/ruby extconf.rb
checking for socket() in -lsocket... no
checking for gethostbyname() in -lnsl... no
checking for atan() in -lm... no
checking for atan() in -lm... no
*** 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=/opt/rubystack-2.0-0/ruby/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-zlib-dir
    --without-zlib-dir
    --with-zlib-include
    --without-zlib-include=${zlib-dir}/include
    --with-zlib-lib
    --without-zlib-lib=${zlib-dir}/lib
    --with-socketlib
    --without-socketlib
    --with-nsllib
    --without-nsllib
    --with-mlib
    --without-mlib
    --with-mlib
    --without-mlib
 extconf failure: need libm


Gem files will remain installed in /opt/rubystack-2.0-0/ruby/lib/ruby/gems/1.8/gems/libxml-ruby-2.6.0 for inspection.
Results logged to /opt/rubystack-2.0-0/ruby/lib/ruby/gems/1.8/gems/libxml-ruby-2.6.0/ext/libxml/gem_make.out

这是mkmf.log的输出:


have_library: checking for atan() in -lm... -------------------- no

"gcc -o conftest -I. -I/opt/rubystack-2.0-0/ruby/lib/ruby/1.8/i686-linux -I. -DAI_ADDRCONFIG=0 -I/opt/rubystack-2.0-0/common/include  -D_FILE_OFFSET_BITS=64 -DAI_ADDRCONFIG=0 -I/opt/rubystack-2.0-0/common/include  -g -Os -fno-strict-aliasing -L/opt/rubystack-2.0-0/common/lib   -fno-builtin conftest.c  -L. -L/opt/rubystack-2.0-0/ruby/lib -Wl,-R/opt/rubystack-2.0-0/ruby/lib -L/opt/rubystack-2.0-0/ruby/lib -Wl,-R/opt/rubystack-2.0-0/ruby/lib -L. -L/opt/rubystack-2.0-0/common/lib -ltcmalloc_minimal -rdynamic -Wl,-export-dynamic     -lruby-static -lm  -lpthread -lrt -ldl -lcrypt -lm   -lc"
conftest.c: In function ‘t’:
conftest.c:3: error: ‘atan’ undeclared (first use in this function)
conftest.c:3: error: (Each undeclared identifier is reported only once
conftest.c:3: error: for each function it appears in.)
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { void ((*volatile p)()); p = (void ((*)()))atan; return 0; }
/* end */

"gcc -o conftest -I. -I/opt/rubystack-2.0-0/ruby/lib/ruby/1.8/i686-linux -I. -DAI_ADDRCONFIG=0 -I/opt/rubystack-2.0-0/common/include  -D_FILE_OFFSET_BITS=64 -DAI_ADDRCONFIG=0 -I/opt/rubystack-2.0-0/common/include  -g -Os -fno-strict-aliasing -L/opt/rubystack-2.0-0/common/lib   -fno-builtin conftest.c  -L. -L/opt/rubystack-2.0-0/ruby/lib -Wl,-R/opt/rubystack-2.0-0/ruby/lib -L/opt/rubystack-2.0-0/ruby/lib -Wl,-R/opt/rubystack-2.0-0/ruby/lib -L. -L/opt/rubystack-2.0-0/common/lib -ltcmalloc_minimal -rdynamic -Wl,-export-dynamic     -lruby-static -lm  -lpthread -lrt -ldl -lcrypt -lm   -lc"
/usr/bin/ld: cannot find -lruby-static
collect2: ld returned 1 exit status
checked program was:
/* begin */
1: /*top*/
2: int main() { return 0; }
3: int t() { atan(); return 0; }
/* end */

我在virtualbox 4.2.8中使用http://sourceforge.net/projects/virtualrails/

使用gem 1.3.5

它包含两个错误:

  • conftest.c:3:错误:'atan'未声明(首次使用此功能)

  • / usr / bin / ld:找不到-lruby-static

第一个错误'atan'很容易解决,但第二个错误不确定是否有一个库丢失或者是否是一个更大的问题所有这一切

2 个答案:

答案 0 :(得分:0)

https://github.com/xml4r/libxml-ruby#requirements

  

libxml-ruby需要Ruby 1.8.4或更高版本。这取决于   以下库正常运行:
    - libm(数学例程:非常标准)
    - libz(zlib)
    - libiconv
    - libxml2
  如果您运行的是Linux或Unix,则需要一个C编译器,以便在安装时可以编译扩展。

确保在构建gem之前拥有所有这些

答案 1 :(得分:0)

sudo apt-get install libxslt-dev libxml2-dev

sudo gem install libxml-ruby