我尝试了几个小时(现在几天…)来安装Nokogiri 1.6.3我以为我可以在Nokogiri网站(http://nokogiri.org/tutorialsinstalling_nokogiri.html)上做一个声明,但它失败了,需要开发工具安装…
/Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:456:in `try_do':
The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/yves/.rbenv/versions/2.1.2/lib/ruby/2.1.0/mkmf.rb:587:in `try_cpp'
我正在使用XCode 5.1,并安装了开发工具!否则我无法安装libiconv库…
yves$ ./configure --prefix=/usr/local/Cellar/libiconv/1.14
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
...
yves$ gcc -v
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.3.0
Thread model: posix
我浏览了与这个问题相关的所有问题/答案(许多情况,许多给定的解决方案;…)但是Nokogiri 1.6.3(最新更新)
只是为了检查,我尝试安装gem ffi,它也需要构建本机扩展,并且它很好…
yves$ gem install ffi
Fetching: ffi-1.9.3.gem (100%)
Building native extensions. This could take a while...
Successfully installed ffi-1.9.3
1 gem installed
是的,这是Nokgiri 1.6.3的依赖问题。试试以下命令:
gem install nokogiri -- --use-system-libraries --with-xml2-include=/usr/local/Cellar/libxml2/2.7.8/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.7.8/lib --with-xslt-dir=/usr/local/Cellar/libxslt/1.1.28 --with-iconv-include=/usr/local/Cellar/libiconv/1.13.1/include --with-iconv-lib=/usr/local/Cellar/libiconv/1.13.1/lib
在执行此操作之前,请确保系统中安装了正确的libxml2、libxslt和libiconv版本,并且上述路径也正确。