Installing from sources
Get one of the source tarballs from http://ftp.mozilla.org/pub/mozilla.org/js/ (1.7.0 or 1.8.0-rc1 will do).
- Unpack the tarball. Note that once extracted the source are in the directory "js", without the expected version suffix.
- Go to the js/src directory.
Build SpiderMonkey. There is no default Makefile, use Makefile.ref. The default build is debug, use BUILD_OPT=1 for an optimized build.
make BUILD_OPT=1 -f Makefile.ref
Install SpiderMonkey. Instead of "install" the target to use is "export". Instead of PREFIX the target directory is specified with JS_DIST.
sudo make BUILD_OPT=1 JS_DIST=/usr/local -f Makefile.ref export
Notes when installing on OS X
- The export needs to be run as root so use $ sudo sh
- When running ./configure for couchdb you will need to use the --with-js-include and --with-js-lib options
You will need to make sure /usr/local/spidermonkey/lib is in DYLD_LIBRARY_PATH export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/usr/local/spidermonkey/lib
If you're still getting dyld: Library not loaded: Darwin_OPT.OBJ/libjs.dylib when trying to start couchdb, run ranlib /usr/local/spidermonkey/libjs.a
Notes when installing on Linux
It would be best if you can install the SpiderMonkey libraries via your system's package management system, eg:
apt-get install libmozjs-dev
yum install js-devel
Warning: Yum may install an older version of SpiderMonkey (1.5) that doesn't work with CouchDB. If you see build errors related to JSOPTION_NATIVE_BRANCH_CALLBACK, you will need to build a newer version of SpiderMonkey as mentioned above.
However, if you need to install from source you should make sure spidermonkey's lib directory is in LD_LIBRARY_PATH:
Or if this does not work for you, set the /lib and /include locations when running ./configure by using something similar to:
./configure --with-js-lib=/usr/local/spidermonkey/lib --with-js-include=/usr/local/spidermonkey/include
If you get a message like this during "yum install js-devel":
No package js-devel available. Nothing to do
you may need to add a yum repository. Add rpmforge.repo in /etc/yum.repos.d containing:
# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag # URL: http://rpmforge.net/ [rpmforge] name = Red Hat Enterprise $releasever - RPMforge.net - dag baseurl = ftp://ftp.pbone.net/mirror/atrpms.net/el5-i386/atrpms/stable enabled = 1 protect = 0 gpgcheck = 0
(Put "x86_64" instead of "i386" if when appropriate.)
yum clean all yum install js-devel
and you should be OK.
Installing on Linux for CouchDB versions >= 1.1
Directions adapted from:
Add RPMForge repo as detailed above (for mercurial, a prerequisite of SpiderMonkey)
Install SpiderMonkey prerequisites (copied from above link)
yum install \ cvs zip gcc-c++ glib2-devel gtk2-devel fontconfig-devel libnotify-devel \ libIDL-devel alsa-lib-devel libXt-devel freetype-devel pkgconfig \ dbus-glib-devel curl-devel autoconf213 xorg-x11-proto-devel libX11-devel \ libXau-devel libXext-devel wireless-tools-devel glibc-static libstdc++-static yasm \ mesa-libGL-devel esound-libs esound-devel ccache mercurial
Download a version of SpiderMonkey >= 1.8.5 (CouchDB's ./configure script looks for mozjs185 to determine JS library existence)
curl -L -O http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar xvf js185-1.0.0.tar.gz cd js-1.8.5/js/src
- Install. 'make install' is needed to move the final files into position, despite it being omitted from Mozilla's process
autoconf-2.13 ./configure make make install
- Use the following ./configure line for CouchDB
./configure --with-erlang=/wherever/your/erlang/install/is --with-js-lib=/usr/local/lib/ --with-js-include=/usr/local/include/js/
Notes when installing on Android
Please see the Android-specific "installing from source" instructions. Since support for Android was added fairly recently to Spidermonkey and NSPR, the above notes won't be of much help to you.