make php error: libjpeg.(a|so), libpng.(a|so) not found.

近來凍仁會在 CentOS 5.6 x86_64 的環境上編譯 PHP (v5.2.17),也很巧的遇見同樣問題兩次,不過比較詭異的地方是,當初同事是遇到「configure: error: Cannot find libmysqlclient_r under /usr/local/mysql.」的錯誤訊息,但換凍仁接手時就變成「configure: error: libpng.(a|so) not found.」了。

由於環境是 x86_64 (64 bit) 的關係,會同時有 /usr/lib 以及 /usr/lib64 兩函式庫,所以只要把 /usr/lib 裡缺少的東西連結過來即可。
root@centos:~$ ln -s /usr/lib64/libpng.a /usr/lib/ [Enter]
root@centos:~$ ln -s /usr/lib64/libpng.so /usr/lib/ [Enter]

重跑一次編譯設定,若成功會顯示以下訊息。
root@centos:~$ ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-config-file-path=/etc --enable-mbstring=tw --enable-ftp --with-gd --with-zlib --with-regex=php --with-iconv --enable-sockets --enable-fastcgi --with-apxs2=/usr/local/apache/bin/apxs --with-jpeg-dir --with-png-dir [Enter]
......
|--------------------------------------------------------------------|
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
|--------------------------------------------------------------------|
Thank you for using PHP.

開始編譯,完成後會看到「Build complete.」訊息。
root@centos:~$ make && make install [Enter]

2012-05-02


今日同樣的動作又遇到「configure: error: libjpeg.(a|so) not found.」的錯誤訊息,一樣需手動連結 lib 至對應的檔名即可。
root@centos:~$ ln -fs /usr/lib/libjpeg.so.62.0.0 /usr/lib/libjpeg.so

參考連結:
apache mysql php gd freetds-Linux系统-Linux系统中文网
[PHP] GD with JPEG / imagejpeg @ FreeBSD @ 第二十四個夏天後

留言

Popular Articles

sudo 指令使用說明