Building Spider Monkey

MongoDB uses SpiderMonkey for server-side Javascript execution.

Pre v2.0: MongoDB requires a js.lib file when linking. This page details how to build js.lib.

v2.0+: this is handled automatically by the Mongo build scripts via files under third_party/ in the MongoDB project directory.

Note: V8 Javascript support is under development.

Building js.lib - Unix

Remove any existing xulrunner

First find out what has been installed

dpkg -l | grep xulrunner

e.g.

ubuntu910-server64:mongo$ sudo dpkg -l | grep xul
ii  xulrunner-1.9.1                   1.9.1.13+build1+nobinonly-0ubuntu0.9.10.1 XUL + XPCOM application runner
ii  xulrunner-1.9.1-dev               1.9.1.13+build1+nobinonly-0ubuntu0.9.10.1 XUL + XPCOM development files

Next remove the two installed packages

sudo apt-get remove xulrunner-1.9.1-dev xulrunner-1.9.1

Download

curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar zxvf js-1.7.0.tar.gz

Build

cd js/src
export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref

SpiderMonkey does not use UTF-8 by default, so we enable before building.

An experimental SConstruct build file is available here.

Install

JS_DIST=/usr make -f Makefile.ref export

By default, the mongo scons project expects spidermonkey to be located at ../js/.

Building js.lib - Windows

Prebuilt

Alternatively, follow the steps below to build yourself.

Download

From an msysgit or cygwin shell, run:

curl -O ftp://ftp.mozilla.org/pub/mozilla.org/js/js-1.7.0.tar.gz
tar zxvf js-1.7.0.tar.gz

Build

cd js/src

export CFLAGS="-DJS_C_STRINGS_ARE_UTF8"
make -f Makefile.ref

If cl.exe is not found, launch Tools...Visual Studio Command Prompt from inside Visual Studio -- your path should then be correct for make.

If you do not have a suitable make utility installed, you may prefer to build using scons. An experimental SConstruct file to build the js.lib is available in the mongodb/snippets project. For example:

cd
git clone git://github.com/mongodb/mongo-snippets.git
cp mongo-snippets/jslib-sconstruct js/src/SConstruct
cd js/src
scons

Troubleshooting scons

Note that scons does not use your PATH to find Visual Studio. If you get an error running cl.exe, try changing the following line in the msvc.py scons source file from:

MVSdir = os.getenv('ProgramFiles') + r'\Microsoft Visual Studio 8'

to

MVSdir = os.getenv('ProgramFiles') + r'\Microsoft Visual Studio ' + version

See Also


Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

PLEASE POST QUESTIONS IN THE USER GROUPS FORUM. Post non-question comments and helpful hints here.

blog comments powered by Disqus