DBD::mysql 在 Catalina/Big 上安装 Sur 失败,未找到 'EXTERN.h' 文件?

DBD::mysql installation on Catalina/Big Sur fail with 'EXTERN.h' file not found?

我在 Catalina 上安装 DBD::mysql 准备:

perl Makefile.PL --testpassword=s3kr1t --testhost=localhost --testport 3306 --testuser=test --libs="-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient"

在 运行 'make' 之后我得到一个错误:

/Library/Perl/5.18/darwin-thread-multi-2level/auto/DBI/DBIXS.h:22:10: fatal error: 'EXTERN.h' file not found 

秒。 DBD::mysql::INSTALL

看看EXTERN.h:

$ find /Library/Developer/CommandLineTools -name EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h

检查您的 perl 版本:

$ perl -v

This is perl 5, version 18, subversion 4 (v5.18.4) built for darwin-thread-multi-2level

右边header是:

/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h

使用正确的 OSX header 这样它就可以工作了:

perl Makefile.PL --testpassword=s3kr1t --testhost=localhost --testport 3306 --testuser=test --libs="-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.25_1/lib -lmysqlclient" --cflags='-I/usr/local/opt/openssl/include -I/usr/local/opt/zlib/include -I/usr/local/opt/zstd/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -I/usr/local/Cellar/mysql/8.0.25_1/include/mysql'

PS,不要忘记创建具有所有权限的 mysql 用户 'test' :-)

查看详情:

升级 OSX 11.1 - 大苏尔:

如果我采取上面的方式,我首先得到错误:

./dbdimp.h:20:10: fatal error: 'DBIXS.h' file not found
#include <DBIXS.h>  /* installed by the DBI module                        */

修复方法是,将 perl Makefile.PL 扩展为:

perl Makefile.PL --testpassword=s3kr1t --testhost=localhost --testport 3306 --testuser=test --libs="-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.25_1/lib -lmysqlclient" --cflags='-I/usr/local/opt/openssl/include -I/usr/local/opt/zlib/include -I/usr/local/opt/zstd/include -I/Library/Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE -I/usr/local/Cellar/mysql/8.0.25_1/include/mysql -I/Library//Developer/CommandLineTools/SDKs/MacOSX11.1.sdk/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/DBI'

下一个问题是:

make: *** No rule to make target `/System/Library/Perl/Extras/5.30/darwin-thread-multi-2level/auto/DBI/Driver_xst.h', needed by `mysql.xsi'.  Stop.

这是为什么? Big Sur 上 DBI 的默认安装已损坏!

下载当前 DBI 存档 DBI-1.643.tar.gz 并重新安装 DBI 后 DBD::mysql 使 运行 完成!

现在我必须休息 :-) 经过 2 小时的尝试和错误!!!