PHP在构建时未正确链接MySQL共享库
作者:互联网
我正在尝试使用此配置在新计算机上构建PHP:
export MACOSX_DEPLOYMENT_TARGET=10.7 CFLAGS="-arch x86_64" CXXFLAGS="-arch x86_64" LIBS=-lresolv
export DYLD_LIBRARY_PATH=/usr/local/mysql/lib
./configure --prefix=/usr/local --with-apxs2=/usr/sbin/apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli --with-zlib-dir=/usr --enable-exif --enable-ftp --enable-mbstring --enable-mbregex --enable-sockets --with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc --sysconfdir=/private/etc --with-mysql-sock=/var/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql --with-openssl=/usr --with-xmlrpc --with-xsl=/usr --without-pear --with-libxml-dir=/usr --with-iconv=/usr/local --with-pdo-mysql=/usr/local/mysql/bin/mysql_config --with-gd --with-jpeg-dir=/usr/local/Cellar --with-png-dir=/usr/X11 --with-freetype-dir=/usr/X11 --with-mcrypt=/usr/local/Cellar --enable-pcntl
配置运行正常,但是当我尝试运行“ make”时,它会出现以下错误:
Generating phar.phar
dyld: Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/mdiamond/Downloads/php-5.3.8/sapi/cli/php
Reason: image not found
make: *** [ext/phar/phar.phar] Trace/BPT trap: 5
考虑到我指定了“ export DYLD_LIBRARY_PATH = /usr/local/mysql / lib”,而libmysqlclient.18.dylib在该路径中,因此这很奇怪.似乎链接程序正在寻找没有路径(在根目录中)的libmysqlclient.18.dylib.我也在我的php二进制文件上运行了otool并得到了这个:
/usr/lib/libexslt.0.dylib (compatibility version 9.0.0, current version 9.13.0)
/usr/lib/libiodbc.2.dylib (compatibility version 4.0.0, current version 4.18.0)
libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
/usr/local/lib/libmcrypt.4.dylib (compatibility version 9.0.0, current version 9.8.0)
/usr/local/lib/libltdl.7.dylib (compatibility version 11.0.0, current version 11.0.0)
/System/Library/Frameworks/LDAP.framework/Versions/A/LDAP (compatibility version 1.0.0, current version 2.2.0)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/X11/lib/libfreetype.6.dylib (compatibility version 13.0.0, current version 13.2.0)
/usr/X11/lib/libpng15.15.dylib (compatibility version 17.0.0, current version 17.0.0)
/usr/local/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
/usr/local/lib/libjpeg.8.dylib (compatibility version 12.0.0, current version 12.0.0)
/usr/lib/libcrypto.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
/usr/lib/libssl.0.9.8.dylib (compatibility version 0.9.8, current version 0.9.8)
/usr/lib/libcurl.4.dylib (compatibility version 7.0.0, current version 7.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 159.0.0)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 46.0.0)
/usr/lib/libxml2.2.dylib (compatibility version 10.0.0, current version 10.3.0)
/usr/lib/libicucore.A.dylib (compatibility version 1.0.0, current version 46.1.0)
/System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos (compatibility version 5.0.0, current version 6.0.0)
/usr/lib/libxslt.1.dylib (compatibility version 3.0.0, current version 3.24.0)
注意libmysqlclient如何是唯一没有路径的库.有谁知道我该怎么解决?我运行配置错误吗?
解决方法:
我有一个类似的问题,我认为这与以下事实有关:/usr/local/mysql在我的计算机(通过DMG安装的MySQL)上与/usr/local/mysql-5.5.15-osx10.6-x86_64符号链接.更改DYLD_LIBRARY_PATH以使用完全限定的路径似乎可以使我工作.
但是,在make install过程中确实遇到了后续问题.在安装PEAR环境步骤期间,出现了相同的错误消息.解决该问题的方法是事先执行以下操作:
install_name_tool -change libmysqlclient.18.dylib \
/usr/local/mysql-5.5.15-osx10.6-x86_64/lib/libmysqlclient.18.dylib \
/path/to/php-5.3.8/sapi/cli/php
标签:makefile,shared-libraries,mysql,php 来源: https://codeday.me/bug/20191208/2088079.html