QuickJS
QuickJS copied to clipboard
Script evaluation not working!
``extern "C" { #include <quickjs/quickjs.h> }
int main() { JSRuntime* runtime = JS_NewRuntime(); JSContext* context = JS_NewContext(runtime);
JS_Eval(context, "10 + 10", 7, "noname", 0);
JS_FreeContext(context);
JS_FreeRuntime(runtime);
}`` This does not work, when I put a break point on the JS_Eval line and continue, it gives read access violation error in find_hashed_shape_proto() on "rt". PLEASE help!
@hassan-aman how did you make?
What do you mean? (I apologize for the dirty and unformatted question I originally posted)
I actually used the MSVC version of this library and generated a project through premake: premake5 vs2019
. I built it into a static library and linked it against another project (which is literally one source file) containing that code.
The reason I did this is because I am on Windows and using Visual Studio 2019. I cannot include Linux files like <dirent.h> and whatnot.
i don't have Windows machine, i tried this on Mac
#include "quickjs-libc.h"
int main(int argc, char **argv) {
JSRuntime *rt = JS_NewRuntime();
JSContext *ctx = JS_NewContextRaw(rt);
JS_AddIntrinsicBaseObjects(ctx);
js_std_add_helpers(ctx, argc, argv);
JS_Eval(ctx, "10 + 10", 7, "noname", 0);
js_std_loop(ctx);
JS_FreeContext(ctx);
JS_FreeRuntime(rt);
return 0;
}
i build it with gcc test.c libquickjs.lto.a
and no problem to me
you can also build hello.c
to test your environment
@hassan-aman the official quickjs github repo has been setup, please open a issue there https://github.com/bellard/quickjs/issues
@hassan-aman please check this quickjs for visual studio build https://github.com/c-smile/quickjspp/