64位系统下编译PHP找不到库文件问题


最近在64位系统上编译5.4.5版的PHP时,遇到报以下错:

  1. checking for DSA_get_default_method in -lssl... yes  
  2. checking for X509_free in -lcrypto... yes  
  3. checking for pkg-config... /usr/bin/pkg-config  
  4. configure: error: Cannot find OpenSSL's libraries  

指定的编译参数:

  1. ./configure \  
  2. --prefix=/usr/local/services/php-5.4.5 \  
  3. --with-config-file-path=/usr/local/services/php-5.4.5/etc \  
  4. --enable-fpm \  
  5. --enable-mbstring \  
  6. --enable-soap \  
  7. --enable-sockets \  
  8. --enable-zip \  
  9. --with-curl=/usr \  
  10. --with-mysql=mysqlnd \  
  11. --with-mysqli=mysqlnd \  
  12. --with-pdo-mysql=mysqlnd \  
  13. --with-gd \  
  14. --with-jpeg-dir=/usr \  
  15. --with-png-dir=/usr \  
  16. --with-zlib-dir=/usr \  
  17. --with-freetype-dir=/usr \  
  18. --with-openssl=/usr  

找不到openssl的库文件,但我明明有安装openssl-devel的,很奇怪,网上搜了一下,发现有很多朋友,遇到了同样的问题,有些人说--with-openssl不指定路径可解决,尝试了一下,的确编译通过了,但想不通,Why?后来,又搜了一些文章来看,终于找出问题的根源:安装的系统是64位的,而64位的用户库文件默认是在/usr/lib64,而我编译的时候,没有指定--with-libdir=lib64,而编译脚本默认是lib,这当然是找不到的。

将编译参数更改为:

  1. ./configure \  
  2. --prefix=/usr/local/services/php-5.4.5 \  
  3. --with-config-file-path=/usr/local/services/php-5.4.5/etc \  
  4. --enable-fpm \  
  5. --enable-mbstring \  
  6. --enable-soap \  
  7. --enable-sockets \  
  8. --enable-zip \  
  9. --with-curl=/usr \  
  10. --with-mysql=mysqlnd \  
  11. --with-mysqli=mysqlnd \  
  12. --with-pdo-mysql=mysqlnd \  
  13. --with-gd \  
  14. --with-jpeg-dir=/usr \  
  15. --with-png-dir=/usr \  
  16. --with-zlib-dir=/usr \  
  17. --with-freetype-dir=/usr \  
  18. --with-openssl=/usr \  
  19. --with-libdir=lib64  

问题解决。

相关内容