perl操作MongoDB報(bào)錯(cuò)undefined symbol: HeUTF8解決方法
因?yàn)閟hell操作mongo比較麻煩,只好嘗試使用perl操作mongo,perl需要操作mongodb必須先安裝相應(yīng)的驅(qū)動(dòng),大部分人使用cpan安裝,個(gè)人覺(jué)得太麻煩,使用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報(bào)錯(cuò)了,使用–force參數(shù)
# 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
看起來(lái)一切完好。測(cè)試腳本
腳本內(nèi)容:
# cat /root/testMongo.pl
#!/usr/bin/perl
use MongoDB;
my $connection = MongoDB::Connection->new( host => 'localhost', port => 27017);
運(yùn)行:
# 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”,只發(fā)現(xiàn)一篇相關(guān)文章.一群人討論這個(gè)問(wèn)題。其中一個(gè)人的解決方法如下:
# 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
添加如下內(nèi)容到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腳本運(yùn)行ok.
實(shí)際上是因?yàn)椴患嫒莸膯?wèn)題,對(duì)于系統(tǒng)RHEL5/CENTOS5發(fā)行版,mongodb的perl驅(qū)動(dòng)最后的一個(gè)版本是v0.45
如下是國(guó)外網(wǎng)友的回復(fù):
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
相關(guān)文章
perl中chomp的使用介紹(chop和chomp函數(shù)區(qū)別)
perl程序中,有時(shí)在輸入過(guò)程中使用chomp才會(huì)得到正確的結(jié)果2013-02-02
perl 標(biāo)量和運(yùn)算符的一些知識(shí)介紹
有關(guān)perl的標(biāo)量和運(yùn)算符的一些知識(shí),有需要的朋友可以看看2013-02-02
讓apache2以cgi方式運(yùn)行perl cgi程序的實(shí)現(xiàn)方法
讓apache2以cgi方式運(yùn)行perl cgi程序的方法,供大家學(xué)習(xí)參考2013-02-02

