2014-05-09 22 views
0

我試圖在Mac OS X 10.9.2上構建和安裝nokogiri Rubygem,它需要libxml2。薪火--with-xml2-lib--with-xml2-include選項似乎沒有生效帶附加包含和lib路徑的gem install

$ gem install nokogiri -- --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/libxml2 --with-xml2-lib=/usr/local/lib 

設置LDFLAGS和CPPFLAGS確實是(使用的libxml2代替的Xcode的自制版)

$ LDFLAGS="-L/usr/local/opt/libxslt/lib -L/usr/local/opt/libxml2/lib" CPPFLAGS="-I/usr/local/opt/libxslt/include -I/usr/local/opt/libxml2/include" gem install -r nokogiri 

錯誤輸出始終是不行的同樣

checking for libxml/parser.h... yes 
checking for libxslt/xslt.h... yes 
checking for libexslt/exslt.h... yes 
checking for iconv_open() in iconv.h... yes 
checking for xmlParseDoc() in -lxml2... no 
----- 
libxml2 is missing. please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies. 
----- 
*** 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=/usr/local/Cellar/ruby/2.1.1_1/bin/ruby 
    --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-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=${xml2-dir}/include 
    --with-xml2-lib=${xml2-dir}/lib 
    --with-xslt-dir 
    --with-xslt-include 
    --without-xslt-include=${xslt-dir}/include 
    --with-xslt-lib 
    --without-xslt-lib=${xslt-dir}/lib 
    --with-libxslt-config 
    --without-libxslt-config 
    --with-pkg-config 
    --without-pkg-config 
    --with-libxml-2.0-config 
    --without-libxml-2.0-config 
    --with-libiconv-config 
    --without-libiconv-config 
    --with-xml2lib 
    --without-xml2lib 

extconf failed, exit code 1 

回答

2

使用自制安裝寶石取決於實際安裝寶石做的伎倆在我面前,然後再設置NOKOGIRI_USE_SYSTEM_LIBRARIES=1庫。

彙總:

  • 如果以前安裝,卸載寶石:
    $ gem uninstall nokogiri

  • 使用自制安裝libxml2libxsltlibiconv
    $ brew install libxml2 libxslt libiconv

  • 安裝寶石指定pa部份的圖書館對鏈接:
    $ NOKOGIRI_USE_SYSTEM_LIBRARIES=1 gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"

+0

不明白爲什麼人們不重視你的答案。我認爲這是真正有價值的信息和平。謝啦! – Andry

1

我有同樣的問題,但對我來說了以下工作:

gem install -- --with-opt-include=/usr/local/opt/libxml2/include/libxml2