开发者

MongoDB SpiderMonkey doesn't understand UTF-8

If I add non-ASCII characters to MongoDB database then all db.find() fail telling "non ascii character detected".

It's problem of SpiderMonkey, I have to rebuild it with UTF-8 support. I've tried to do it like in http://www.mongodb.org/display/DOCS/Building+Spider+Monkey

but it doesn't work (SpiderMonkey is not installed after I've completed all steps).

I've got Ubuntu 11.04. Does anybody have instruction how to make it work ther开发者_StackOverflow社区e?

Working instruction how to make work MongoDB with Google V8 can also help.


I'm using MongoDB on Ubuntu Server 11.04, installed it after making fresh OS install using this instruction: http://www.mongodb.org/display/DOCS/Ubuntu+and+Debian+packages Everything is working fine out of the box. Is it critical for you to build MongoDB from scratch?


Using the 10gen-published packages works fine, but if you actually want to compile SpiderMonkey from source with UFT-8 support:

curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvzf js185-1.0.0.tar.gz
cd js-1.8.5/js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
export CXXFLAGS="-DJS_C_STRINGS_ARE_UTF8"

And then follow the instructions from https://developer.mozilla.org/En/SpiderMonkey/Build_Documentation

autoconf-2.13
./configure
make
make install
cp js /usr/local/bin/

This will install into /usr/local/lib, however the mongodb package looks for it in /usr/lib (where the spidermonkey package is installed). So, we link all files installed to /usr/local /lib from /usr/lib

ln -s /usr/local/lib/libmozjs185.so /usr/lib/libmozjs185.so
ln -s /usr/local/lib/libmozjs185.so.1.0 /usr/lib/libmozjs185.so.1.0
ln -s /usr/local/lib/libmozjs185.so.1.0.0 /usr/lib/libmozjs185.so.1.0.0
ln -s /usr/local/lib/libmozjs185-1.0.a /usr/lib/libmozjs185-1.0.a

Of course you could just move them into /usr/lib instead of symlinking, but I wanted to keep the utf-enabled libs away from the default location, to prevent conflicts with the default spidermonkey package. Without the libmozjs package installed, apt complains that dependencies for mongodb are not satisfied, so I've left it installed.

Keep in mind that if the spidermonkey package gets upgraded, it can overwrite the symlinks to our new libs (or the libs themselves if you've moved them to /usr/local/lib). The ideal solution would be to build your own package to solve dependency issues for good.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜