User Tools

Site Tools


Compiling SpiderMonkey

In the case where you do not want to or cannot download the pre-made SpiderMonkey libraries, there is always the option of compiling SpiderMonkey yourself. Avidemux only needs a Mozilla JavaScript library and the jsapi.h associated source files.

You will need to download the JavaScript SpiderMonkey engine. This is usually called simple 'js' for Javascript. This can be done by searching for the SpiderMonkey development package in your package manager. Depending on the your distribution of Linux, it can be called libsmjs, libmozjs, or libjs or something like that. We suggest you search for these names or something with “spidermonkey” and “dev”.

It usually has the name by using the 'apt-get install' or 'apt-rpm install' or 'emerge' systems on your various Linux distributions.

Method A

If you cannot use your distributions package or install system to automatically download a copy of the SpiderMonkey package, here is an link to a currently working version:

Extract the downloaded source files it into a directory. For example, let's call the directory: /home/user/JavaScript_src/

Run these commands from a console:

cd /home/user/JavaScript_src/js/src
make -f Makefile.ref   # (or gmake in the case of some distributions)

The next step depends a lot on your distribution of Linux. Choose one that applies to you.

General compile steps

These are the normal commands for compiling SpiderMonkey. They may vary depending on your Linux distribution. Please look at the other sections on this page for specific settings for different Linux distributions.

./configure (with your extra arguments if necessary)
make install

Debian, Gentoo, Ubuntu

This process will not work for most Ubuntu systems version 6.10. We suggest you try Method B.

We are not certain if this process works for Gentoo, but it might. Feel free to correct the instructions if they are wrong for Gentoo.

mkdir /usr/include/smjs
cp /home/user/JavaScript_src/js/src/Linux_All_DBG.OBJ/jsautocfg.h /usr/include/smjs/jsautocfg.h
cp /home/user/JavaScript_src/js/src/Linux_All_DBG.OBJ/ /usr/lib/
cp /home/user/JavaScript_src/js/src/Linux_All_DBG.OBJ/*.h /usr/include/smjs/

Lastly edit /etc/ and add the line /usr/lib. Now you may proceed with compilation of Avidemux.

Gentoo custom compile

Building a thread safe version of SpiderMonkey requires the “Netscape Portable Runtime” (NSPR) library.


To setup the proper compile environment, run these commands from a console:


Install the NSPR library

As root run from console:

emerge nspr

Install the SpiderMonkey source

You can use the “js-1.5.tar.gz” archive from the Mozilla website at After you download it, unpack the archive and go to the ./js/src/ directory.

Edit the Makefile

Edit the Makefile.ref to reflect the “NSPR” install. Lines after the comments (starting with #) are the edited version of the original line:

# INCLUDES += -I../../dist/$(OBJDIR)/include
INCLUDES += -I/usr/include/nspr
ifdef USE_MSVC
OTHER_LIBS += ../../dist/$(OBJDIR)/lib/libnspr${NSPR_LIBSUFFIX}.lib
# OTHER_LIBS += -L../../dist/$(OBJDIR)/lib -lnspr${NSPR_LIBSUFFIX}
OTHER_LIBS += -L/usr/lib/nspr -lnspr4

Build SpiderMonkey

Next we need to build SpiderMonkey. For “debug” version (default), run this command from a console:

make -f Makefile.ref

For “release” version, run this command from a console:

make -f Makefile.ref BUILD_OPT=1

Install SpiderMonkey

If you have a previous version of SpiderMonkey emerged, then just overwrite it with. Run these commands from a root console:

cp *.h /usr/include/js
# For default debug version:
cp Linux_All_DBG.OBJ/ /usr/lib
# For release version:
cp Linux_All_OPT.OPJ/ /usr/lib

If you don't have a previous version of SpiderMonkey, then just create the “/usr/include/js” directory.

Red Hat/(Slackware)

This is valid for Red Hat, but some people do not like this solution for Slackware. See the Slackware section for other options.

mkdir /usr/local/include/js 
cp /home/user/JavaScript_src/js-1.5.tar.gz_FILES/js/src/Linux_All_OPT.OBJ/jsautocfg.h /usr/local/include/js/jsautocfg.h 
cp /home/user/JavaScript_src/js-1.5.tar.gz_FILES/js/src/Linux_All_OPT.OBJ/ /usr/local/lib/ 
cp /home/user/JavaScript_src/js-1.5.tar.gz_FILES/js/src/*.h /usr/local/include/js/

Lastly edit /etc/ and add the line /usr/local/lib. Now you may proceed with compilation of Avidemux.

Compiling ThreadSafe SpiderMonkey

  1. Run these commands from a root console or with the sudo command if you are able:
    install nspr-devel
    yum install nspr-devel

    This will create the directory /usr/include/nspr4/.

  2. Download SpiderMonkey to /tmp from the Mozilla website. We used version 1.5.rc4, but it should not really matter.
  3. Extract the downloaded source file to /usr/local/src. It should create a js/ directory there.
  4. Step into the main build directory
    cd js/src
  5. Modify the SpiderMonkey Makefile so that it compiles in 'threadsafe' mode. First copy the makefile.ref file to the makefile.
     cp Makefile.ref Makefile
  6. Next open the Makefile in your favorite text editor.
  7. Change the INCLUDES line below the ifdef JS_THREADSAFE section like this:
    FROM : INCLUDES += -I../../dist/$(OBJDIR)/include
    TO: INCLUDES += -I/usr/include/nspr4
  8. Compile SpiderMonkey with the following:
    export JS_THREADSAFE=1
  9. Copy (or link) the just created to /usr/lib (so that it can be found in final Avidemux link step with no fuss)
    cp Linux_All_DBG.OBJ/ /usr/lib
  10. When you compile Avidemux itself, you need to run the ./configure with the argument --with-jsapi-include=/usr/local/src/js/src


On Slackware there are no precompiled packages for libjs, so you can either try to do something with the source files. There is the Library Error/Failure section if you want to try a trick with symlinks. Another option is that you can avoid installing the libraries altogether and compile Avidemux against the Mozilla webbrowser. If you have the Mozilla installed, you can try this trick instead of symlinks.

You will need to find the location of your copy of Mozilla.



--with-jsapi-include=/usr/include/mozilla-1.7.11/js/  \

This is the extra arguments you would use in the ./configure step during the Avidemux compiling, not the SpiderMonkey library compiling.

Method B

Here is how to compile the library yourself another way. These instructions are currently only tested on Ubuntu, but they should work for most distributions of Linux.

Debian, Ubuntu

You need to download the source files. When you run this run this command, it will download the source files to your current console location. If you run the command as root, it will set the owner of the files as root, so beware you may need to change the ownership.

From a root console or via sudo run this command:

sudo apt-get source libmozjs-dev libidl-dev

This will grab the source code packages for the SpiderMonkey development library. The download will be very large, and will include a lot of files besides the ones you are interested in. Do not worry, this is normal. The IDL library is a dependency for compiling. Once the file download is complete, it should automatically be extracted. The directory will probably have a name like xulrunner-1.x.x.x with the 'x' representing version numbers.

From a console run these commands:

cd xulrunner-1.x.x.x # Where the xxxx are the version numbers
./configure \
--enable-application=standalone \
--disable-mailnews \
--disable-ldap \
--disable-gnomevfs \
--disable-gnomeui \
--disable-jsd \
--disable-plugins \
--disable-oji \
--disable-view-source \
--disable-accessibility \
--disable-jsloader \
--disable-composer \
--disable-postscript \
--disable-xtf \
--disable-xpfe-components \
--disable-xpinstall \
--disable-xprint \
--disable-xpcom-obsolete \
--disable-mathml \
--disable-installer \
--disable-updater \
--disable-activex \
--disable-activex-scripting \
--disable-xul \
--disable-profilesharing \
--disable-profilelocking \
--disable-necko-disk-cache \
--disable-cookies \
--disable-v1-string-abi \

The 'make' command will take a very long time to finish. When it is done, from a console run these commands:

cd xulrunner-1.x.x.x # Where the xxxx are the version numbers
sudo cp js/src/ /usr/lib/

Now you have successfully compiled the library and you can delete the xulrunner files.

Library error/failure

When doing the configure, if you used the --prefix for jsapi.h, but there is an error at the library stage, locate or or on your system. Then symbolically link it to /usr/local/lib or /usr/lib

build/compile_spidermonkey.txt · Last modified: 2012/11/11 08:51 (external edit)