2016-04-28 70 views
0

當試圖安裝使用本機擴展的ruby gem時,我的安裝失敗。Ruby本地擴展寶石安裝失敗

Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 

日誌文件給我下面的輸出

"gcc-mp-4.9 -o conftest -I/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/include/ruby-1.9.1/x86_64-darwin13.4.0 -I/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/include/ruby-1.9.1/ruby/backward -I/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -O3 -ggdb -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wimplicit-function-declaration -fno-common -pipe conftest.c -L. -L/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib -L/opt/local/lib -L. -L/opt/local/lib  -lruby.1.9.1 -lpthread -ldl -lobjc " 
checked program was: 
/* begin */ 
1: #include "ruby.h" 
2: 
3: int main(int argc, char **argv) 
4: { 
5: return 0; 
6: } 
/* end */ 

看來這是找GCC的MacPorts的版本,而不是使用該系統的gcc,但我甚至不具有任何MacPorts的GCC安裝在系統上。

------編輯從gem_make.out文件中添加輸出---------

/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20160428-64282-8h2kw8.rb extconf.rb 
checking for main() in -lcups... *** 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 
    --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=/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/bin/ruby 
    --with-cupslib 
    --without-cupslib 
/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError) 
You have to install development tools first. 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:461:in `try_link0' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:476:in `try_link' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:619:in `try_func' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:845:in `block in have_library' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
    from /Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/mkmf.rb:840:in `have_library' 
    from extconf.rb:3:in `<main>' 

extconf failed, exit code 1 
+0

您使用的是RBENV還是RVM? –

+0

我正在使用RVM。 – bigtunacan

+0

應該有更詳細的堆棧跟蹤以及構建錯誤。但看看它試圖編譯什麼,我會說你的編譯器壞了,或者你錯過了ruby頭文件。 – photoionized

回答

0

它結束了,海灣合作委員會的設置是爲rbconfig.rb文件粘rvm gemset。

我不得不去

~/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/x86_64-darwin13.4.0/rbconfig.rb 

在那裏,我不得不改變

CONFIG["CC"] = "gcc-mp-4.9" 

CONFIG["CC"] = "gcc" 

,改變

CONFIG["configure_args"] = " '--prefix=/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551' '--with-opt-dir=/opt/local' '--without-tcl' '--without-tk' '--disable-install-doc' '--enable-shared' 'CC=gcc-mp-4.9'" 

CONFIG["configure_args"] = " '--prefix=/Users/bigtunacan/.rvm/rubies/ruby-1.9.3-p551' '--with-opt-dir=/opt/local' '--without-tcl' '--without-tk' '--disable-install-doc' '--enable-shared' 'CC=gcc'"