Skip to content

Instantly share code, notes, and snippets.

@udzura
Created September 3, 2009 03:38
Show Gist options
  • Save udzura/180118 to your computer and use it in GitHub Desktop.
Save udzura/180118 to your computer and use it in GitHub Desktop.
cat /etc/issue
#=> CentOS release 4.7 (Final)
#=>Kernel \r on an \m
wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
tar xzf libxml2-2.7.3.tar.gz
cd libxml2-2.7.3
./configure --prefix=/usr/local/libxml
make
echo $?
make install
cd ../
tar xzf libxslt-1.1.24.tar.gz
cd libxslt-1.1.24
./configure --prefix=/usr/local/libxml --with-libxml-prefix=/usr/local/libxml
make
echo $?
make install
# http://d.hatena.ne.jp/kitamomonga/20090617/ruby_nokogiri_let_use_libxml2_in_home
ruby -rubygems -e "require 'nokogiri'; p Nokogiri::VERSION_INFO"
#=>WARNING: Nokogiri was built against LibXML version 2.6.16, but has dynamically loaded 2.7.3
#=>{"nokogiri"=>"1.3.3", "warnings"=>["Nokogiri was built against LibXML version 2.6.16, but has dynamically loaded 2.7.3"], "libxml"=>{"compiled"=>"2.6.16", "loaded"=>"2.7.3", "binding"=>"extension"}}
# http://wiki.github.com/tenderlove/nokogiri/what-to-do-if-libxml2-is-being-a-jerk
gem install nokogiri --no-ri --no-rdoc -- --with-xml2-lib=/usr/local/libxml/lib \
--with-xml2-include=/usr/local/libxml/include/libxml2 \
--with-xslt-dir=/usr/local/libxml \
--with-cflags="-L/usr/local/libxml/lib -Wl,-rpath,/usr/local/libxml/lib" \
--with-ldflags=-Wl,-rpath,/usr/local/libxml/lib
ldconfig -v
cp -p /usr/local/libxml/lib/libexslt.so.0 /usr/local/libxml/lib/libxml2.so.2 /usr/local/libxml/lib/libxslt.so.1 /usr/lib/tls
# http://www.ecoop.net/memo/2008-01-28-2.html
export LD_PRELOAD=/usr/local/libxml/lib/libxml2.so.2:/usr/local/libxml/lib/libxslt.so.1:/usr/local/libxml/lib/libexslt.so.0
ruby -rubygems -e "require 'nokogiri'; p Nokogiri::VERSION_INFO"
#=> {"nokogiri"=>"1.3.3", "warnings"=>[], "libxml"=>{"compiled"=>"2.7.3", "loaded"=>"2.7.3", "binding"=>"extension"}}
ldd /usr/lib/ruby/gems/1.8/gems/nokogiri-1.3.3/lib/nokogiri/nokogiri.so
#=> /usr/local/libxml/lib/libxml2.so.2 (0x00e15000)
#=> /usr/local/libxml/lib/libxslt.so.1 (0x00c65000)
#=> /usr/local/libxml/lib/libexslt.so.0 (0x00111000)
gem install mechanize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment