/ Build On Linux

Building Jsi on Linux

Jsi is written in C, but can be compiled as either native C, or native C++ (does not use extern C).

On Debian a few packages are required:

sudo apt-get install build-essential bison libreadline-dev libsqlite3-dev libwebsockets-dev libncurses-dev cmake libmysqlclient-dev

Note: Some packages (eg. cmake) are required only for specific configurations.

To build the Linux target there are are two steps:


Do not be surprised to see comiler output from configure:

it compiles the stripped down shell "jsimin".

Next, run "make" to build the actual "jsish" executable.


If you want, you can see other available options using:

./configure --help

Note: The directory Configs/, which contains a number of predefined configurations which can be copied to make.conf

The last step is to run the test suite (optional):

make test


If you are on a debian system, you can build then install as a package:

cd tools
sudo dpkg -i jsish-*


On FreeBSD use "gmake" instead of "make" and:

pkg install fetch gmake bison


Jsi can be cross compiled from Linux to Windows using the Mingw32 package:

sudo apt-get install gcc-mingw-w64

The sqlite and libwebsockets source needs to be downloaded and unpacked in "../sqlite" and "../websockets". This now happens automatically.

Then configure using:

./configure --config=win

WARNING: Certain features (eg. signals) are disabled in the Windows build. There are also differences in some of the file-system access functions.


The standalone build produces a static binary that contains no external library references. This is useful when you need a standalone executable with no external dependancies.

To create a static image, Jsi uses the Musl library.

The first step is to download Musl and unpack it. Then change to the musl dir and run configure/make, eg:

 ./configure --prefix=$HOME/usr && make install

Ensure that ~/usr/bin is in your path with export PATH=$PATH:$HOME/usr/bin. Then back in the jsi dir do the following:

echo '#define __P(x) x' > ~/usr/include/sys/cdefs.h
echo '#include <miniz/zlib.h>' >  ~/usr/include/zlib.h
cp -pr miniz ~/usr/include/

The sqlite and libwebsockets source needs to be downloaded and unpacked in ../sqlite and ../websockets.

The static jsish can then be built with:

./configure --config=musl


Amalgamated source is the easiest way to incorporate Jsi into an existing application: Here is a simple example:

#include "jsi.c"

int main(int argc, char *argv[])
    Jsi_Interp *interp = Jsi_InterpNew(NULL);
    Jsi_EvalString(interp, "for (var i=1; i<=3; i++)  puts('TEST:',i);", 0);
    if (argc>1)
        Jsi_EvalFile(interp, Jsi_ValueNewStringKey(interp, argv[1]), 0);

which we compile with:

gcc  myfile.c -lm -lz -ldl -lpthread

Another alternative that simplifies debugging Jsi is using jsiOne.c