Can't load '/usr/local/lib64/perl5/auto/Net/ZooKeeper/ZooKeeper.so' for module Net::ZooKeeper: /usr/local/lib64/perl5/auto/Net/ZooKeeper/ZooKeeper.so: undefined symbol: ZOO_PERM_CREATE at /usr/lib64/perl5/XSLoader.pm line 70.
at /usr/local/lib64/perl5/Net/ZooKeeper.pm line 109.
查看XSLoader.pm的70行:
1
2
3
4
70 my $libref = dl_load_file($file, 0) or do {
71 require Carp;
72 Carp::croak("Can't load '$file' for module $module: " . dl_error());
73 };
[zhangbin@localhost zkperl]$ perl Makefile.PL
Warning (mostly harmless): No library found for -lzookeeper_mt
Generating a Unix-style Makefile
Writing Makefile for Net::ZooKeeper
Writing MYMETA.yml and MYMETA.json
注意第一行的warning,这是解决问题的关键。Most harmless,but harm this time。查看 Makefile.PL的 第31行
[zhangbin@localhost zkperl]$ perl Makefile.PL --zookeeper-lib=/home/zhangbin/env/lib
Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Net::ZooKeeper
Writing MYMETA.yml and MYMETA.json
然后make && sudo make install。问题解决。
可能XSLoader没有自动从LD_LIBRARY_PATH寻找可用的库和符号表的机制。