2

这看起来已经存在多年了 - 但我找不到任何最新的和与 Mac 相关的东西,并且只处理安装 CPAN 模块 DBD::mysql 我已经在互联网上搜索了好几天了......

#   Failed test 'use DBD::mysql;'
#   at t/00base.t line 15.
#     Tried to use 'DBD::mysql'.
#     Error:  Can't load '/Users/robert/.cpanm/work/1542100720.91387/DBD-mysql-4.048/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/robert/.cpanm/work/1542100720.91387/DBD-mysql-4.048/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Symbol not found: _mysql_affected_rows
#   Referenced from: /Users/robert/.cpanm/work/1542100720.91387/DBD-mysql-4.048/blib/arch/auto/DBD/mysql/mysql.bundle
#   Expected in: flat namespace
#  in /Users/robert/.cpanm/work/1542100720.91387/DBD-mysql-4.048/blib/arch/auto/DBD/mysql/mysql.bundle at /usr/local/Cellar/perl/5.28.0/lib/perl5/5.28.0/darwin-thread-multi-2level/DynaLoader.pm line 197.
# ^@ at t/00base.t line 15.
# Compilation failed in require at t/00base.t line 15.
# BEGIN failed--compilation aborted at t/00base.t line 15.
Bailout called.  Further testing stopped:  Unable to load DBD::mysql
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 255
-> FAIL Installing DBD::mysql failed. See /Users/robert/.cpanm/work/1542100720.91387/build.log for details. Retry with --force to force install it.

这是我正在使用的 cpanm 线。

sudo cpanm  --configure-args="--libs='-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.12/lib' --cflags='-I/usr/local/opt/openssl/include -I/usr/local/include/mysql -I/usr/local/Cellar/mysql/8.0.12/include/mysql'" DBD::mysql

我已经用 Homebrew 安装了 mysql,以及其他一切。我什至已经将一些库复制到系统目录中——但似乎没有什么想让这个 cpan 模块安装和工作。

编辑:此行之后的添加。让我们尝试手工制作包装

sudo perl Makefile.PL --libs="-L/usr/local/opt/openssl/lib -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.12/lib -lssl -lcrypto"

制作的结果。看起来不错。我在这里没有看到任何错误。显然所有库都可用于编译。

zeus:DBD-mysql-4.048-0 robert$ sudo perl Makefile.PL --libs="-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.12/lib"
I will use the following settings for compiling and testing:

  cflags        (mysql_config ) = -I/usr/local/Cellar/mysql/8.0.12/include/mysql
  embedded      (guessed      ) = 
  libs          (User's choice) = -L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.12/lib
  mysql_config  (Users choice ) = mysql_config
  nocatchstderr (default      ) = 0
  nofoundrows   (default      ) = 0
  nossl         (default      ) = 0
  testdb        (User's choice) = test
  testhost      (default      ) = 
  testpassword  (default      ) = 
  testport      (default      ) = 
  testsocket    (default      ) = 
  testuser      (User's choice) = root

To change these settings, see 'perl Makefile.PL --help' and
'perldoc DBD::mysql::INSTALL'.

Checking if libs are available for compiling...
Looks good.

Checking if your kit is complete...
Looks good
Using DBI 1.642 (for perl 5.028000 on darwin-thread-multi-2level) installed in /usr/local/Cellar/perl/5.28.0/lib/perl5/site_perl/5.28.0/darwin-thread-multi-2level/auto/DBI/
Generating a Unix-style Makefile
Writing Makefile for DBD::mysql
Writing MYMETA.yml and MYMETA.json
zeus:DBD-mysql-4.048-0 robert$ 

现在让我们看看make是否有效。

看起来不错。1 个关于 WIDEST_UTYPE 的警告,但这只是一个警告......

然后,制作 mysql.bundle

chmod 755 blib/arch/auto/DBD/mysql/mysql.bundle
Manifying 3 pod documents

好的,现在是大考验。进行测试

......它失败了。

zeus:DBD-mysql-4.048-0 robert$ sudo make test
"/usr/local/Cellar/perl/5.28.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- mysql.bs blib/arch/auto/DBD/mysql/mysql.bs 644
PERL_DL_NONLAZY=1 "/usr/local/Cellar/perl/5.28.0/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00base.t .............................. 1/6 
#   Failed test 'use DBD::mysql;'
#   at t/00base.t line 15.
#     Tried to use 'DBD::mysql'.
#     Error:  Can't load '/Users/robert/.cpan/build/DBD-mysql-4.048-0/blib/arch/auto/DBD/mysql/mysql.bundle' for module DBD::mysql: dlopen(/Users/robert/.cpan/build/DBD-mysql-4.048-0/blib/arch/auto/DBD/mysql/mysql.bundle, 2): Symbol not found: _mysql_affected_rows
#   Referenced from: /Users/robert/.cpan/build/DBD-mysql-4.048-0/blib/arch/auto/DBD/mysql/mysql.bundle
#   Expected in: flat namespace
#  in /Users/robert/.cpan/build/DBD-mysql-4.048-0/blib/arch/auto/DBD/mysql/mysql.bundle at /usr/local/Cellar/perl/5.28.0/lib/perl5/5.28.0/darwin-thread-multi-2level/DynaLoader.pm line 197.
#  at t/00base.t line 15.
# Compilation failed in require at t/00base.t line 15.
# BEGIN failed--compilation aborted at t/00base.t line 15.
Bailout called.  Further testing stopped:  Unable to load DBD::mysql
FAILED--Further testing stopped: Unable to load DBD::mysql
make: *** [test_dynamic] Error 255

……就在那里。同样的错误。现在我也尝试了 MariaDB - 结果相同,尽管错误消息略有不同。

我在这里想念什么。

4

1 回答 1

14

所以我终于找到了。当然,它正在正确定位库和包含文件。

所以我进入了我系统上的 cpan 目录

/Users/robert/.cpan/build/DBD-mysql-4.048-0

在检查了 openssl 和 mysql 的 brew 安装位置后,我醒来了。

sudo perl Makefile.PL --libs="-L/usr/local/opt/openssl/lib -lssl -lcrypto -L/usr/local/lib -L/usr/local/Cellar/mysql/8.0.12/lib -lmysqlclient"

现在。之所以有效,是因为在查看 mysaql lib 目录后,我看到该库是“mysqlclient”而不是 mysql。正如你在上面看到的。

现在可以像上面那样做 Makefile.PL 了。

然后'make'起作用了。如上。没有显示任何错误...如上

然后sudo make test 工作- 这次。

All tests successful.
Files=73, Tests=9, 11 wallclock secs ( 0.24 usr  0.15 sys +  8.25 cusr  1.23 csys =  9.87 CPU)
Result: PASS

最后 - 进行安装。工作过

zeus:DBD-mysql-4.048-0 robert$ sudo make install
"/usr/local/Cellar/perl/5.28.0/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- mysql.bs blib/arch/auto/DBD/mysql/mysql.bs 644
Manifying 3 pod documents
Files found in blib/arch: installing files in blib/lib into architecture dependent library tree
Installing /usr/local/Cellar/perl/5.28.0/lib/perl5/site_perl/5.28.0/darwin-thread-multi-2level/auto/DBD/mysql/mysql.bundle
Installing /usr/local/Cellar/perl/5.28.0/lib/perl5/site_perl/5.28.0/darwin-thread-multi-2level/Bundle/DBD/mysql.pm
Installing /usr/local/Cellar/perl/5.28.0/lib/perl5/site_perl/5.28.0/darwin-thread-multi-2level/DBD/mysql.pm
Installing /usr/local/Cellar/perl/5.28.0/lib/perl5/site_perl/5.28.0/darwin-thread-multi-2level/DBD/mysql/INSTALL.pod
Installing /usr/local/Cellar/perl/5.28.0/lib/perl5/site_perl/5.28.0/darwin-thread-multi-2level/DBD/mysql/GetInfo.pm
Installing /usr/local/Cellar/perl/5.28.0/share/man/man3/Bundle::DBD::mysql.3
Installing /usr/local/Cellar/perl/5.28.0/share/man/man3/DBD::mysql::INSTALL.3
Installing /usr/local/Cellar/perl/5.28.0/share/man/man3/DBD::mysql.3
Appending installation info to /usr/local/Cellar/perl/5.28.0/lib/perl5/5.28.0/darwin-thread-multi-2level/perllocal.pod
zeus:DBD-mysql-4.048-0 robert$ pwd
/Users/robert/.cpan/build/DBD-mysql-4.048-0

最后好。现在我为什么要这个?我不记得了。

于 2018-11-13T14:19:46.210 回答