Not logged in

Jsi is written in C, but compiles as either native C, or native C++ (without use of extern C).

Building Jsi

Building Jsi on Ubuntu requires a few packages:

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

Some of these (eg. cmake) are only required 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

Lastly, if you want you can run the test suite with:

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.

Then configure using:

./configure --config=win

Note that 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);
    Jsi_EvalFile(interp, argv[1], 0);

which we compile with:

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

Another alternative that simplifies debugging Jsi is using ../jsiOne.c (then linking against jsiOne.a).

For more details, see Using Jsi, Jsi-Lite or DBQuery.


A Basic Extension

The source for a basic extension is shown in ../c-demos/demo1.c, which creates a new javascript method demo() that simply echo's its arguments.

We can build this into a jsish shell with:

gcc -o demo1 -g -I.. -DJSI_USER_EXTENSION=Jsi_Initdemo1 demo1.c ../jsish.c ../main.c -lm -lz -ldl -lpthreads

and run with:

# demo(1,2,3)
demo called with 3 args
Arg 0 = '1'
Arg 1 = '2'
Arg 2 = '3'

Alternatively, we can just call Jsi_Initdemo1(interp) from our own amalgamation.

Multi-method Extension

It is often more useful to create multiple related commands within a single object.

The source in ../c-demos/demo2.c does exactly this, which again we build it with:

gcc -o demo2 -g -I.. -DJSI_USER_EXTENSION=Jsi_Initdemo2 demo2.c ../jsish.c ../main.c -lm -lz -ldl -lpthreads

Now we have several new javascript methods

C++ Support

The Jsi source code is both valid C and valid C++. This means it will build with: "make CC=g++"

Getting Help

Having problems?