Skip to content

new modules and how to host or publish them #1091

Answered by bnoordhuis
coreyapowell asked this question in Q&A
Discussion options

You must be logged in to vote

quickjs is primarily a library intended for consumption by downstream projects. qjs is more of an afterthought, a toy shell; it's not the primary product. The common case is you a) build quickjs and your project with cmake or meson, or b) drop quickjs-amalgam.c + quickjs.h (and optionally: quickjs-libc.h) in your project.

Publishing modules: it sounds like the .so loader is what you want. If you don't want to depend on quickjs-libc, the loader is literally nothing more than this:

union { void *p; JSModule (*f)(JSContext *, const char *); } u;
void *h = dlopen("foo.so", RTLD_NOW|RTLD_LOCAL); // error handling elided
u.p = dlsym(h, "js_init_module");
u.f(ctx, "foo"); // name of module

We co…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by coreyapowell
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants