QJSC(1)

NAME
qjsc - The QuickJS JavaScript compiler

The qjsc executable runs the JavaScript compiler, it can generate bytecode from source files which can then be embedded in an executable, or it can generate the necessary scaffolding to build a C application which embeds QuickJS.

    $ qjsc
    usage: qjsc [options] [files]

    options are:
    -b          output raw bytecode instead of C code
    -e          output main() and bytecode in a C file
    -o output   set the output filename
    -n script_name    set the script name (as used in stack traces)
    -N cname    set the C name of the generated data
    -m          compile as JavaScript module (default=autodetect)
    -D module_name         compile a dynamically loaded module or worker
    -M module_name[,cname] add initialization code for an external C module
    -p prefix   set the prefix of the generated C names
    -s          strip the source code, specify twice to also strip debug info
    -S n        set the maximum stack size to 'n' bytes (default=262144)

Here is an example on how to create a standalone executable that embeds QuickJS and the examples/hello.js JavaScript file:

    # Make sure you are in the QuickJS source directory.
    $ cc hello.c dtoa.c libregexp.c libunicode.c quickjs.c quickjs-libc.c -I. -o hello

The resulting binary hello will be in the current directory.

    $ ./hello
    Hello World

:::note See the "Creating standalone executables" section for a simpler way.