Question

I've been trying to learn spidermonkey and so have written the following code, adapted from this guide and while the program compiles properly, I get the following error during linking:

/usr/bin/ld: cannot open linker script file symverscript: No such file or directory

I'm using 64-bit Ubuntu 13.10, and here is the code (seems irrelevant to the problem, but can't hurt)

#include <jsapi.h>
#include <iostream>
#include <string>

int main()
{
    std::string script = "var x = 10;x*x;";
    jsval rval;
    JSRuntime* runtime = 0;
    JSContext* context = 0;
    JSObject* globalob = 0;
    if((!(runtime = JS_NewRuntime(1024L*1024L, JS_NO_HELPER_THREADS)))||
        (!(context = JS_NewContext(runtime, 8192)))||
        (!(globalob  = JS_NewObject(context, NULL, NULL, NULL))))
    {
        return 1;
    }
    if(!JS_InitStandardClasses(context, globalob))
    {
        return 1;
    }
    if(!JS_EvaluateScript(context,globalob,script.data(),script.length(),"script",1,&rval))
    {
        return 1;
    }
    std::cout << JSVAL_TO_INT(rval) << "\n";
    JS_DestroyContext(context);
    JS_DestroyRuntime(runtime);
    JS_ShutDown();
    return 0;
}

compiled with the command

g++ main.cpp -o out $(js24-config --cflags --libs | tr "\n" " ")
Was it helpful?

Solution

Try to write this command instead, g++ main.cpp -o main -I/usr/local/include/js/ -L/usr/local/lib/ -lmozjs1.8.5

regarding the path I wrote above, you must write your own path which include the library and JSAPI.h file included in, And the last term is spidermonkey library, you will find it in lib folder, for me it exists in /usr/local/lib

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top