SBaronda.com a little place I like to call home.


QuickJS - Compiling hello.c

Mar. 26, 2021

Out of an interest of getting QuickJS bindings working in Crystal, I needed to figure out how to compile the hello.c which has the bare bones C implementation needed to start from. This is how I did it:

curl -O -L https://bellard.org/quickjs/quickjs-2020-11-08.tar.xz
tar xvf quickjs-2020-11-08.tar.xz
cd quickjs-2020-11-08
make
clang hello.c -L.  -lquickjs -lm -lpthread -ldl
./a.out
Hello World

To compile against the object files, which might be easier for your integration you'd do:

clang -c -o hello.o hello.c
cang -o hello hello.o .obj/quickjs.nolto.o .obj/libregexp.nolto.o .obj/libunicode.nolto.o .obj/cutils.nolto.o .obj/quickjs-libc.nolto.o .obj/libbf.nolto.o -lm -ldl -lpthread

My clang version:

clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

More QuickJS <> Crystal bindings in the future.


comments powered by Disqus