[quickjs-devel] Re: How to compile hello.c

  • From: kimown <kimown@xxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Tue, 27 Aug 2019 16:50:44 +0800 (CST)

Thanks, I compile it in linux, so I have to use gcc, but gcc throw error.

gcc -o hello libquickjs.a hello.c

/tmp/ccWCp9HS.o: In function `main':
hello.c:(.text+0x10): undefined reference to `JS_NewRuntime'
hello.c:(.text+0x20): undefined reference to `JS_NewContextRaw'
hello.c:(.text+0x30): undefined reference to `JS_AddIntrinsicBaseObjects'
hello.c:(.text+0x45): undefined reference to `js_std_add_helpers'
hello.c:(.text+0x62): undefined reference to `js_std_eval_binary'
hello.c:(.text+0x6e): undefined reference to `js_std_loop'
hello.c:(.text+0x7a): undefined reference to `JS_FreeContext'
hello.c:(.text+0x86): undefined reference to `JS_FreeRuntime'
collect2: error: ld returned 1 exit status

At 2019-08-27 16:06:57, "Vincent Chan" <okcdz@diverse.space> wrote:
You need to make libquickjs.a first:


$ make libquickjs.a


Then, compile you’re hello.c and link the libquickjs.a


$ clang hello.c -g -o hello ./libquickjs.a



On Aug 27, 2019, at 4:04 PM, kimown <kimown@xxxxxxx> wrote:


hello.c
/* File generated automatically by the QuickJS compiler. */


I can generate hello.c from qjsc, but can I compile it using gcc or clang?

Other related posts: