【发布时间】:2013-12-31 08:00:00
【问题描述】:
我一直在尝试学习 spidermonkey,因此编写了以下代码,改编自 this guide,当程序正确编译时,在链接过程中出现以下错误:
/usr/bin/ld: cannot open linker script file symverscript: No such file or directory
我使用的是 64 位 Ubuntu 13.10,这里是代码(似乎与问题无关,但不会受到伤害)
#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;
}
用命令编译
g++ main.cpp -o out $(js24-config --cflags --libs | tr "\n" " ")
【问题讨论】:
标签: c++ linker spidermonkey