Post date: 2017/04/01 10:23:49
For some reason, rootになれないので、yum installはできない前提。
1.zlibとic4c-58(sharlock_holmes)は、ソースからprefix=/usr/local/anagix_toolsにインストール
zlibをインストールせずにrubyをbuild-rubyできる。しかし、zlibがリンクされないため、bundlerのインストールで以下のエラーになる:
gem install bundler --no-ri --no-rdoc
ERROR: Loading command: install (LoadError)
cannot load such file -- zlib
zlibインストール後、build-rubyしなおしたが、rubyを実行すると以下のようなエラーになる。
/usr/local/anagix_tools/ruby233/bin/ruby: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by /usr/local/anagix_tools/ruby233/bin/ruby)
/usr/local/anagix_tools/ruby233/bin/ruby: /lib64/libc.so.6: version `GLIBC_2.17' not found (required by /usr/local/anagix_tools/ruby233/bin/ruby)
なので、以下に続く。
2.rubyは、別マシーンのcentos6.8でbuild-rubyし、/usr/local/anagix_tools/ruby233にコピーした
It worked あ
wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
./config shared zlib --prefix=/usr/local/anagix_tools --openssldir=/usr/local/anagix_tools/openssl --with-zlib-lib=/usr/local/anagix_tools/lib --with-zlib-include=/usr/local/anagix_tools/include
wget ftp://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz
./configure --prefix=/usr/local/anagix_tools
3.bundle installするとsharlock_holmesで止まる。
yum install libicu-develできればよいのかも知れないが、ic4c-58をソースから入れる
4.gem install charlock_holmes -v 0.7.3 -- --with-icu-lib=/usr/local/anagix_tools/lib --with-icu-include=/usr/local/anagix_tools/include --no-ri --no-rdoc
はできるが、bundle installでは以下のトリックが必要。
bundle config --local build.charlock_holmes --with-icu-lib=/usr/local/anagix_tools/lib --with-icu-include=/usr/local/anagix_tools/include
これで、/usr/local/anagix_tools/alb2/.bundle/configに以下の記述が入る:
BUNDLE_BUILD__CHARLOCK_HOLMES: "--with-icu-lib=/usr/local/anagix_tools/lib --with-icu-include=/usr/local/anagix_tools/include"
あらためて bundle install
5. mysql2のgem installで以下のエラー:
linking shared-object mysql2/mysql2.so
/usr/bin/ld: cannot find -lmysqlclient_r
原因は、mysql-develが、mysql-devel-5.1.73-7.el6.i686しか入ってないこと。なので、CentOS6.8から、
/usr/lib64/mysql/libmysqlclient.so
/usr/lib64/mysql/libmysqlclient_r.so
をコピーし、/usr/local/anagix_tools/libに置く。
6. 同様に、libhistory.so* libreadline.so* libcrypto.so* libssl.so* をCentOS6.8からコピー
gem install mysql2 -- --with-mysql-lib=/usr/local/anagix_tools/lib --with-ssl-lib=/usr/local/anagix_tools/lib --with-readline-lib=/usr/local/anagix_tools/lib --no-ri --no-rdoc
Building native extensions with: '--with-mysql-lib=/usr/local/anagix_tools/lib --with-ssl-lib=/usr/local/anagix_tools/lib --with-readline-lib=/usr/local/anagix_tools/lib --no-ri --no-rdoc'
が成功する。なので、icuと同様、
bundle config --local build.mysql2 --with-mysql-lib=/usr/local/anagix_tools/lib --with-mysql-lib=/usr/local/anagix_tools/lib --with-ssl-lib=/usr/local/anagix_tools/lib --with-readline-lib=/usr/local/anagix_tools/lib
さらに、libsqlite3.so*をコピーし、
bundle config --local build.sqlite3 --with-sqlite3-lib=/usr/local/anagix_tools/lib
bundle config --local build.nokogiri --with-zlib-lib=/usr/local/anagix_tools/lib
の後、bundle install
7. 次はnokogiriとおもいきや、思いっきりトラブった。
nokogiriは、 --use-system-librariesを指定しない場合、nokogiri内部に組み込まれたlibxml2を使用する。v1.6.7.2の場合、zlib-dirの指定が内部のlibxml2のconfigureの引数にわたらないようだ。
v1.7.1はどちらもうまくいく:
gem install nokogiri -- --with-zlib-dir=/usr/local/anagix_tools --with-zlib-include=/usr/local/anagix_tools/include --with-zlib-lib=/usr/local/anagix_tools/lib --no-ri --no-rdoc
gem install nokogiri -- --use-system-libraries --with-zlib-include=/usr/local/anagix_tools/include --with-zlib-lib=/usr/local/anagix_tools/lib --no-ri --no-rdoc
しかし、v1.6.7.2の場合、--use-system-librariesでない成功しない。gem installは成功するが、bundle installはこの時点では成功していない
メモ: bundle installに引数を渡すには、例えば
bundle config --local build.nokigiri --use-system-libraries --with-zlib-include=/usr/local/anagix_tools/include --with-zlib-lib=/usr/local/anagix_tools/lib
を実行する。すると、.bundle/configに以下の記述が入る
BUNDLE_BUILD__NOKIGIRI: "--use-system-libraries --with-zlib-include=/usr/local/anagix_tools/include --with-zlib-lib=/usr/local/anagix_tools/lib"
8.libxml2、libxsltをソースからインストールするようにしたため、以下もソースからインストールした
wget ftp://xmlsoft.org/libxml2/libxml2-2.9.4.tar.gz
wget ftp://xmlsoft.org/libxml2/libxslt-1.1.29.tar.gz
wget https://gnupg.org/ftp/gcrypt/libgcrypt/libgcrypt-1.7.6.tar.bz2
wget https://gnupg.org/ftp/gcrypt/libgpg-error/libgpg-error-1.27.tar.bz2
wget https://www.cairographics.org/releases/LATEST-cairo-1.14.8
wget https://www.cairographics.org/releases/LATEST-pixman-0.34.0
wget https://sourceforge.net/projects/libpng/files/libpng16/1.6.29/libpng-1.6.29.tar.gz
基本的に、./configure prefix=/usr/local/anagix_toolsで入るが、
export PKG_CONFIG_PATH=/usr/local/anagix_tools/lib/pkgconfig
をしないと、リンクがうまくいかないものもある。
libpngのconfigureは、LDFLAGS="-L/usr/local/anagix_tools/lib -lz" ./configure --prefix=/usr/local/anagix_tools
Freetypeのインストールも必要だったので、
wget http://downloads.sourceforge.net/freetype/freetype-2.7.1.tar.bz2
LDFLAGS="-L/usr/local/anagix_tools/lib -lz" ./configure --prefix=/usr/local/anagix_tools
9.cairoも同様に、
DFLAGS="-L/usr/local/anagix_tools/lib -lz" ./configure --prefix=/usr/local/anagix_tools
10.いよいよ/usr/local/anagix_tools/alb2でbundle update
nokogiri v1.7.1にはエラーはないので、BUNDLE_BUILD__NOKIGIRI: "--use-system-libraries --with-zlib-include=/usr/local/anagix_tools/include --with-zlib-lib=/usr/local/anagix_tools/lib"
がきいているのであろう。--use-system-librariesをやめたらどうなるのか、興味はあるが、いまはやめる。
追記(2018/4/5)
ruby2.5.1で再度インストールを試みたところ、またnokogiriでつまずいた。
export PKG_CONFIG_PATH=/usr/local/anagix_tools/lib/pkgconfig
で解決した。