Installing mechanize gem on Mac OS X 10.4.11 gives 'Failed to build gem native extension'

房东的猫 提交于 2019-12-24 07:38:58

问题


I'm trying to install mechanize gem on a MAC OS X but I keep getting the following error :

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

/usr/local/bin/ruby extconf.rb install mechanize
checking for #include
... yes
checking for #include
... yes
checking for #include
... yes
checking for #include
... yes
checking for xmlParseDoc() in -lxml2... yes
checking for xsltParseStylesheetDoc() in -lxslt... yes
checking for exsltFuncRegister() in -lexslt... yes
creating Makefile

** make gcc -I. -I. -I/usr/local/lib/ruby/1.8/i686-darwin8.9.1 -I. -I/opt/local/include/ -I/opt/local/include/libxml2 -fno-common -g -O2 -pipe -fno-common -g -DXP_UNIX -O3 -Wall -Wcast-qual -Wwrite-strings -Wconversion -Wmissing-noreturn -Winline -c html_document.c
In file included from ./html_document.h:4,
from html_document.c:1:
./native.h:11:28: error: libxml/xmlsave.h: No such file or directory
make: * ** [html_document.o] Error 1**

So xmlsave.h could not be found inside /opt/local/include/ or /opt/local/include/libxml2 The thing is libxml2 is installed as a framework at /Library/Frameworks/libxml2.framework/

Then I decided to create a symlink from libxml headers directory to /opt/local/include/xml2 so I did

ln -s /Library/Frameworks/libxml2.framework/Headers/libxml/ libxml2

but I still can't install the gem.

Any pointers or ideas are very much appreciated.


回答1:


I ran into this same issue, not installing mechanize but webrat. Here's what worked for me:

sudo ln -s /usr/include/libxml2 /opt/local/include/libxml2


来源:https://stackoverflow.com/questions/704544/installing-mechanize-gem-on-mac-os-x-10-4-11-gives-failed-to-build-gem-native-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!