简体   繁体   English

无法在ubuntu中构建gem原生扩展?

[英]Failed to build gem native extension in ubuntu?

I am installing a gem in my ubuntu machine: 我在我的ubuntu机器上安装了一个gem:

gem install tokyocabinet -v '1.29.1'

then I get some errors: 然后我得到一些错误:

ERROR:  Error installing tokyocabinet:
    ERROR: Failed to build gem native extension.

    $HOME/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20150409-9995-bkqyu2.rb extconf.rb
setting variables ...
  $CFLAGS = -I. -I/usr/local/include -Wall $(cflags)  -fPIC -O2
  $LDFLAGS = -L. -fstack-protector -rdynamic -Wl,-export-dynamic -L. -L/usr/local/lib
  $libs =  -ltokyocabinet -lz -lbz2 -lpthread -lm -lc
checking for tcutil.h... *** 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
    ...

$HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:587:in `try_cpp'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:1066:in `block in have_header'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:917:in `block in checking_for'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in `block (2 levels) in postpone'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:321:in `open'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:351:in `block in postpone'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:321:in `open'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:347:in `postpone'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:916:in `checking_for'
    from $HOME/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/mkmf.rb:1065:in `have_header'
    from extconf.rb:26:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in $HOME/.rvm/gems/ruby-2.2.0/gems/tokyocabinet-1.29.1 for inspection.
Results logged to $HOME/.rvm/gems/ruby-2.2.0/extensions/x86_64-linux/2.2.0/tokyocabinet-1.29.1/gem_make.out

it seems that it is something wrong with try_cpp , so it maybe because I do not install gcc or g++ ? 看来try_cpp ,所以可能是因为我没有安装gccg++ But I do install them. 但我确实安装了它们。

checking for tcutil.h... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.

This means that compile tool cannot find tcutil.h , which is included in libtokyocabinet-dev . 这意味着编译工具找不到tcutil.h ,它包含在libtokyocabinet-dev So you have to install it. 所以你必须安装它。

$ sudo apt-get install libtokyocabinet-dev

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM