Mac OSXでPhalconPHPをインストールしようとして、
phalcon.so をbuildした時に詰まったのでメモ。
構成(以降登場するディレクトリはこの辺です)
* ソース置き場 : /usr/local/src
ここの中でgit clone git://github.com/phalcon/cphalcon.gitしました。
* buildした場所 : /usr/local/src/cphalcon/build/64bits
ここで phpize -> ./configure -> make -> make install しています。
* buildされたphalcon.soは : /usr/local/src/cphalcon/build/64bits/modules
の中に現れます。
経緯はいいから、解決方法教えろよ!って方は、下〜〜〜の方にある「 解決 」をご参照ください。
経緯
公式ドキュメント - Linux/Unix/Mac Compilation
の手順に従い
Compilation
1. To create the extension from C source follow these steps:
git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build
sudo ./install
sudo ./installすると、libtoolかな?がこんな感じのエラーをはいた
bash-3.2$ git clone https://github.com/phalcon/cphalcon.git
Cloning into 'cphalcon'...
remote: Counting objects: 33934, done.
remote: Compressing objects: 100% (10558/10558), done.
remote: Total 33934 (delta 25197), reused 31174 (delta 22575)
Receiving objects: 100% (33934/33934), 22.79 MiB | 3.17 MiB/s, done.
Resolving deltas: 100% (25197/25197), done.
bash-3.2$ cd cphalcon/build/
bash-3.2$ ls
32bits 64bits gccarch.c gcccpuopt install pgo-install safe travis-install use-pgo-install
bash-3.2$ sudo ./install
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
glibtoolize: putting auxiliary files in `.'.
glibtoolize: linking file `./ltmain.sh'
glibtoolize: Consider adding `AC_CONFIG_MACRO_DIR([m4])' to configure.in and
glibtoolize: rerunning glibtoolize, to keep the correct libtool macros in-tree.
glibtoolize: Consider adding `-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
(中略)
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
/bin/sh /usr/local/src/cphalcon/build/safe/libtool --mode=compile gcc -I. -I/usr/local/src/cphalcon/build/safe -DPHP_ATOM_INC -I/usr/local/src/cphalcon/build/safe/include -I/usr/local/src/cphalcon/build/safe/main -I/usr/local/src/cphalcon/build/safe -I/usr/local/php5/include/php -I/usr/local/php5/include/php/main -I/usr/local/php5/include/php/TSRM -I/usr/local/php5/include/php/Zend -I/usr/local/php5/include/php/ext -I/usr/local/php5/include/php/ext/date/lib -DHAVE_CONFIG_H -O2 -fno-delete-null-pointer-checks -finline-functions -fomit-frame-pointer -fno-builtin-memcmp -fvisibility=hidden -c /usr/local/src/cphalcon/build/safe/phalcon.c -o phalcon.lo
/usr/local/src/cphalcon/build/safe/libtool: line 862: X--mode=compile: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1029: *** Warning: inferring the mode of operation is deprecated.: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1030: *** Future versions of Libtool will require --mode=MODE be specified.: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: Xgcc: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I.: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/src/cphalcon/build/safe: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-DPHP_ATOM_INC: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/src/cphalcon/build/safe/include: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/src/cphalcon/build/safe/main: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/src/cphalcon/build/safe: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/php5/include/php: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/php5/include/php/main: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/php5/include/php/TSRM: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/php5/include/php/Zend: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/php5/include/php/ext: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-I/usr/local/php5/include/php/ext/date/lib: No such file or directory
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-DHAVE_CONFIG_H: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-O2: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-fno-delete-null-pointer-checks: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-finline-functions: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-fomit-frame-pointer: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-fno-builtin-memcmp: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-fvisibility=hidden: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1173: X-c: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1226: Xphalcon.lo: command not found
/usr/local/src/cphalcon/build/safe/libtool: line 1231: libtool: compile: cannot determine name of library object from `': command not found
make: *** [phalcon.lo] Error 1
長々と書いたけど、⬇あたりから command not found エラーを吐きまくり、phalcon.so を作れず失敗する。
/usr/local/src/cphalcon/build/safe/libtool: line 862: X--mode=compile: command not found
調べてみた結果(URLは失念。。)、libtool(autotool?)のバグらしいというブログ記事を見つけたのだけど、その辺の知識が足りず、対処方法を理解できませんでした。。勉強不足。。
解決
その後、PhalconのForumを検索してみたところ
検索ワード/結果はこちら
こんなIssueが見つかりました。
Compile Error X--mode=compile: command not found
まるっきり同じ現象ですね。
そしてphalconさんのコメントにある通り、公式ドキュメントにあるinstallスクリプトを使わず、下記のようにbuildしてみました。
#build/64bit のところは環境によって書き換えてくださいね。
cd cphalcon
cd build/64bits
export CC="gcc"
export CFLAGS="-O2 -fno-delete-null-pointer-checks -finline-functions -fomit-frame-pointer"
phpize
./configure --enable-phalcon
make && sudo make install
これで、
/usr/local/src/cphalcon/build/64bits/modules
に
phalcon.so
が現れたはず。
これをphpのextension_dirに配置して、php.iniもしくはphp.d/phalcon.iniあたりに
extension=phalcon.so
と書いてあげると、インストール完了です。
もうちょっと詳しく書くと。。。
extension_dirの確認はこうします。
$ php -i | grep extension_dir
extension_dir => /usr/lib/php/extensions/no-debug-non-zts-20090626 => /usr/lib/php/extensions/no-debug-non-zts-20090626
extension_dirに、phalcon.soをこんな感じに配置して、
/usr/lib/php/extensions/no-debug-non-zts-20090626/phalcon.so
php.ini (場所は php -i | grep ini で確認できる)
か、
/usr/local/php5/php.d/phalcon.ini
に
extension=phalcon.so
と書いてあげればOK。
#Apache/nginxなどのwebサーバを使っているなら、webサーバを再起動してあげましょう。
ちゃんとインストールできたかは、下記で確認できます。
$ php -i | grep -i phalcon
/usr/local/php5/php.d/phalcon.ini
phalcon
Phalcon Framework => enabled
Phalcon Version => 1.2.3