perl操作MongoDB报错undefined symbol: HeUTF8解决方法

所属分类: 脚本专栏 / perl 阅读数: 1888
收藏 0 赞 0 分享

因为shell操作mongo比较麻烦,只好尝试使用perl操作mongo,perl需要操作mongodb必须先安装相应的驱动,大部分人使用cpan安装,个人觉得太麻烦,使用cpanm安装perl模块。

复制代码 代码如下:

# cpanm MongoDB
--> Working on MongoDB
Fetching http://www.cpan.org/authors/id/F/FR/FRIEDO/MongoDB-0.702.1.tar.gz ... OK
Configuring MongoDB-0.702.1 ... OK
Building and testing MongoDB-0.702.1 ... FAIL
! Installing MongoDB failed. See /root/.cpanm/work/1376540233.15152/build.log for details. Retry with --force to force install it.

cpanm报错了,使用–force参数

复制代码 代码如下:

# cpanm MongoDB --force
--> Working on MongoDB
Fetching http://www.cpan.org/authors/id/F/FR/FRIEDO/MongoDB-0.702.1.tar.gz ... OK
Configuring MongoDB-0.702.1 ... OK
Building and testing MongoDB-0.702.1 ... FAIL
! Testing MongoDB-0.702.1 failed but installing it anyway.
Successfully installed MongoDB-0.702.1 (upgraded from 0.702.0)
1 distribution installe

看起来一切完好。测试脚本

脚本内容:

复制代码 代码如下:

# cat /root/testMongo.pl
#!/usr/bin/perl
use MongoDB;
my $connection = MongoDB::Connection->new( host => 'localhost', port => 27017);

运行:

复制代码 代码如下:

# perl /root/testMongo.pl
/usr/bin/perl: symbol lookup error: /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/auto/MongoDB/MongoDB.so: undefined symbol: HeUTF8

google查询“MongoDB.so: undefined symbol: HeUTF8”,只发现一篇相关文章.一群人讨论这个问题。其中一个人的解决方法如下:

复制代码 代码如下:

# wget http://search.cpan.org/CPAN/authors/id/F/FR/FRIEDO/MongoDB-0.701.4.tar.gz
# tar -xzvf MongoDB-0.701.4.tar.gz
# cd MongoDB-0.701.4
添加如下内容到perl_mongo.h:
/* supply HeUTF8 if it's missing - ppport.h doesn't supply it, unfortunately */
 #ifndef HeUTF8
 #define HeUTF8(he) ((HeKLEN(he) == HEf_SVKEY) ? \
 SvUTF8(HeKEY_sv(he)) : \
 (U32)HeKUTF8(he))
 #endif
# perl Makefile.PL
# make
# make install

perl脚本运行ok.

实际上是因为不兼容的问题,对于系统RHEL5/CENTOS5发行版,mongodb的perl驱动最后的一个版本是v0.45

如下是国外网友的回复:

The latest version to compile, test and install properly on Rhel5/Centos5 is v0.45 by KRISTINA. (requires Any::Moose)
https://metacpan.org/release/KRISTINA/MongoDB-0.45

更多精彩内容其他人还在看

perl实现检测服务器中的服务是否正常脚本分享

这篇文章主要介绍了perl实现检测服务器中的服务是否正常脚本分享,本文脚本用于检测Linux服务器的服务是否正常,需要的朋友可以参考下
收藏 0 赞 0 分享

perl操作MongoDB报错undefined symbol: HeUTF8解决方法

这篇文章主要介绍了perl操作MongoDB报错undefined symbol: HeUTF8解决方法,需要的朋友可以参考下
收藏 0 赞 0 分享

cpanm安装及Perl模块安装教程

这篇文章主要介绍了cpanm安装及安装Perl模块教程,本文先是给出了cpanm的安装教程,同时给出了Perl模块的安装实例,需要的朋友可以参考下
收藏 0 赞 0 分享

Windows和Linux系统下perl连接SQL Server数据库的方法

这篇文章主要介绍了Windows和Linux系统下perl连接SQL Server数据库的方法,本文详细的讲解了Windows和Linux系统中perl如何连接Microsoft SQL Server数据库,需要的朋友可以参考下
收藏 0 赞 0 分享

Perl脚本实现检测主机心跳信号功能

这篇文章主要介绍了Perl脚本实现检测主机心跳信号功能,本文代码也可作为perl串口通信的实例,需要的朋友可以参考下
收藏 0 赞 0 分享

Perl中使用File::Lockfile确保脚本单实例运行

这篇文章主要介绍了Perl中使用File::Lockfile确保脚本单实例运行的方法,本文直接给出实例,方法非常简单,需要的朋友可以参考下
收藏 0 赞 0 分享

7个perl数组高级操作技巧分享

这篇文章主要介绍了7个perl数组高级操作技巧,本文讲解了数组去重、数组合并、查找最大值、列表归并等内容,需要的朋友可以参考下
收藏 0 赞 0 分享

perl面向对象实例

这篇文章主要介绍了perl面向对象实例,本文讲解了一个类只是一个简单的包、对象仅仅只是引用、一个方法就是一个简单的子程序等内容,并给出了一个简单示例,需要的朋友可以参考下
收藏 0 赞 0 分享

Perl eval函数使用实例

这篇文章主要介绍了Perl eval函数使用实例,本文讲解了eval 函数的两种使用方式,并给出3个使用实例,需要的朋友可以参考下
收藏 0 赞 0 分享

Perl函数(子程序)学习笔记

这篇文章主要介绍了Perl函数(子程序)学习笔记,本文讲解了函数定义、函数返回值、函数参数传递等内容,需要的朋友可以参考下
收藏 0 赞 0 分享
查看更多