QuickJS icon indicating copy to clipboard operation
QuickJS copied to clipboard

Script evaluation not working!

Open for-loop9 opened this issue 4 years ago • 6 comments

``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!

for-loop9 avatar Jun 12 '20 20:06 for-loop9

@hassan-aman how did you make?

ldarren avatar Jun 13 '20 23:06 ldarren

What do you mean? (I apologize for the dirty and unformatted question I originally posted)

for-loop9 avatar Jun 13 '20 23:06 for-loop9

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.

for-loop9 avatar Jun 13 '20 23:06 for-loop9

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

ldarren avatar Jun 14 '20 15:06 ldarren

@hassan-aman the official quickjs github repo has been setup, please open a issue there https://github.com/bellard/quickjs/issues

ldarren avatar Sep 13 '20 14:09 ldarren

@hassan-aman please check this quickjs for visual studio build https://github.com/c-smile/quickjspp/

ldarren avatar Oct 16 '20 12:10 ldarren