Given a simple gcc
command that follows as:
gcc quickrb.c -o main -L /usr/local/lib/quickjs -I /usr/local/lib/quickjs -l quickjs
I'm attempting to wrap this inside of a ruby gem extension extconf.rb
using mkmf
. Currently I've got:
require 'mkmf'
dir_config('quickjs', '/usr/local/lib/quickjs', '/usr/local/include/quickjs')
abort('missing "quickjs.h"') unless find_header('quickjs/quickjs.h')
abort('missing JS_NewRuntime') unless find_library('quickjs', 'JS_NewRuntime', 'quickjs/quickjs.h')
abort('missing JS_NewContext') unless find_library('quickjs', 'JS_NewContext', 'quickjs/quickjs.h')
create_makefile('quickrb/quickrb')
This fails with:
checking for quickjs/quickjs.h... yes
checking for JS_NewRuntime() in -lquickjs... no
missing JS_NewRuntime
I'm unsure how to processed. Without the find_library
calls the Makefile generates, however it fails when compiling with:
dyld: Symbol not found: _JS_NewRuntime
Note:
Here is my sample quickrb.c
file:
#include <quickjs/quickjs.h>
#include <ruby.h>
#include <stdio.h>
#include <strings.h>
void Init_quickrb()
{
const char *filename = "runtime";
const char *script = "3 + 4";
const size_t length = strlen(script);
JSRuntime *runtime = JS_NewRuntime();
JSContext *context = JS_NewContext(runtime);
JSValue value = JS_Eval(context, script, length, filename, JS_EVAL_TYPE_GLOBAL);
const char *result = JS_ToCString(context, value);
printf("%s = %s\n", script, result);
JS_FreeCString(context, result);
JS_FreeContext(context);
JS_FreeRuntime(runtime);
}