I'm trying to use OBJECT_TO_JSVAL function in spidermonkey 1.8.5, and
get the folowing error:
/tmp/ccL9WAb2.o: In function `OBJECT_TO_JSVAL':
runner.c:(.text+0x159): undefined reference to `JSVAL_NULL'
runner.c:(.text+0x15f): undefined reference to `JSVAL_NULL'
collect2: ld returned 1 exit status
Does anybody know the reason why?
Thanks
Is it possible that you are using it in some place where you haven't
included jsapi.h yet, and your compiler is assuming that it is a symbol?
--BDS
On 04/06/11 06:58, Benjamin Smedberg wrote:
> On 6/1/2011 5:57 PM, Dmitry.N.Frolov wrote:
>> Hi,
>>
>> I'm trying to use OBJECT_TO_JSVAL function in spidermonkey 1.8.5, and
>> get the folowing error:
>>
>> /tmp/ccL9WAb2.o: In function `OBJECT_TO_JSVAL':
>> runner.c:(.text+0x159): undefined reference to `JSVAL_NULL'
>> runner.c:(.text+0x15f): undefined reference to `JSVAL_NULL'
>> collect2: ld returned 1 exit status
> JSVAL_NULL is not supposed to be a symbol, it is supposed to be a
> #define, see
> http://mxr.mozilla.org/mozilla-central/source/js/src/jsapi.h#82
That actually depends on the build type (see the comments immediately
above this linked location).
I believe the issue here is that DEBUG was being defined (directly or
indirectly) when the code was compiled, and the resulting objects were
then linking against a release/non-debug build of SpiderMonkey:
$ cat > test.c
#include <jsapi.h>
int main() {
JSObject *obj = NULL;
jsval val = OBJECT_TO_JSVAL(obj);
}
$ gcc `js-config --cflags --libs` -DDEBUG test.c
/tmp/cc5EppAn.o: In function `OBJECT_TO_JSVAL':
test.c:(.text+0x8c): undefined reference to `JSVAL_NULL'
collect2: ld returned 1 exit status
$ gcc `js-config --cflags --libs` test.c
$
Hope this helps,
Paul
_____________________________________________________________________________
This email has been filtered by SMX. For more information visit smxemail.com
_____________________________________________________________________________
> I believe the issue here is that DEBUG was being defined (directly or
> indirectly) when the code was compiled, and the resulting objects were
> then linking against a release/non-debug build of SpiderMonkey:
>
That is an excellent hypothesis.
It is important to remember that you MUST match your JSAPI headers and
shared libraries: they MUST originate from the same configure/build, as
SpiderMonkey's ABI is subject to change when configuration changes. This
has been a source of many bugs in embeddings in the past.
Wes
--
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
You're right, DEBUG was defined. Thanks a lot.