我正在我的 OS X 10.7 Mac 上编写 Perl 模块,当我尝试使用 DBI 模块时遇到了错误。我能够将问题与我的模块分开并通过以下方式重现它:
[sean@mac:~]$ perl -e 'use DBI;'
Can't locate DBI.pm in @INC (@INC contains:
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level
/opt/local/lib/perl5/site_perl/5.12.4
/darwin-multi-2level
/opt/local/lib/perl5/site_perl/5.12.4
/opt/local/lib/perl5
/vendor_perl/5.12.4/darwin-multi-2level
/opt/local/lib/perl5/vendor_perl/5.12.4
/opt/local/lib/perl5/5.12.4/darwin-multi-2level
/opt/local/lib/perl5/5.12.4
/opt/local/lib/perl5/site_perl
/opt/local/lib/perl5/vendor_perl .) at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
这令人费解的原因是:
[sean@mac:~]$ find /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level -iname '*dbi*' -maxdepth 2
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/DBI
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/Bundle/DBI.pm
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/DBI
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/DBI.pm
/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/dbixs_rev.pl
Perl 应该在的地方有一个 DBI 文件夹和一个 DBI.pm 模块!@INC
为什么Perl 找不到包含在路径中的文件?
通过扭动 Perl 的手臂,我找到了一种解决方法:当我在use lib '/System/Library/Perl/Extras/5.12/darwin-thread-multi-2level';
我的模块中添加一行时,Perl 似乎正确地找到了 DBI。但是,在这种情况下,perl -d foo.pm
会导致以下结果:
dyld: lazy symbol binding failed: Symbol not found: _Perl_Gthr_key_ptr
Referenced from: /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/DBI/DBI.bundle
Expected in: flat namespace
dyld: Symbol not found: _Perl_Gthr_key_ptr
Referenced from: /System/Library/Perl/Extras/5.12/darwin-thread-multi-2level/auto/DBI/DBI.bundle
Expected in: flat namespace
Trace/BPT trap: 5
我也不知道如何解释它,所以我对我的解决方法不满意 - 它仍然有“如果你不明白的话,将来会有一个潜在的问题会成为一个令人讨厌的惊喜”的味道出去。”
为什么 DBI 没有正确导入,“惰性符号绑定”调试消息是什么意思?