Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

undefined reference to `JSVAL_NULL'

53 views
Skip to first unread message

Dmitry.N.Frolov

unread,
Jun 1, 2011, 5:57:56 PM6/1/11
to dev-tech-...@lists.mozilla.org
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

Does anybody know the reason why?

Thanks

Benjamin Smedberg

unread,
Jun 3, 2011, 2:58:57 PM6/3/11
to Dmitry.N.Frolov, dev-tech-...@lists.mozilla.org
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

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

Paul Barnetta

unread,
Jun 3, 2011, 6:34:44 PM6/3/11
to dev-tech-...@lists.mozilla.org
Hi there,

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
_____________________________________________________________________________


Wes Garland

unread,
Jun 3, 2011, 10:45:51 PM6/3/11
to Paul Barnetta, dev-tech-...@lists.mozilla.org
On 3 June 2011 18:34, Paul Barnetta <paul.b...@smx.co.nz> wrote:

> 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

Dmitry.N.Frolov

unread,
Jun 4, 2011, 4:58:37 AM6/4/11
to dev-tech-...@lists.mozilla.org
В Птн, 03/06/2011 в 22:45 -0400, Wes Garland пишет:

> On 3 June 2011 18:34, Paul Barnetta <paul.b...@smx.co.nz> wrote:
>
> > 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
>

You're right, DEBUG was defined. Thanks a lot.


0 new messages