Subj : Re: Linking problems To : netscape.public.mozilla.jseng From : Matthew Mondor Date : Tue Jul 19 2005 02:57 pm On Mon, 18 Jul 2005 23:32:08 -0700 Jeremy Gillick wrote: > When I try to compile a simple demo program (see attached) on my apple > powerbook, I get the following error: > > ld: Undefined symbols: > _JS_Init > _JS_InitStandardClasses > _JS_NewContext > _JS_NewObject > > The following files are included in the same directory as simple.c: > > jsapi.h > jsautocfg.h > jscompat.h > jslong.h > jsosdep.h > jsotypes.h > jspubtd.h > jstypes.h > libjs.a > > Any input or direction would be helpful. > > Thanks, > Jeremy > Your source file doesn't need to be in the same directory, and you could use the -I and -L flags to the cc command to specify where they are. You then would include jsapi.h using <> rather than "", that's the way it works for me. You also might want to use -Wl,-R if you are using gcc so that the spidermonkey shared library (if not compiled with -static) doesn't need to be in LD_LIBRARY_PATH. In my case I installed spidermonkey into /usr/local/spidermonkey/, and can both use the shared library, or compile applications statically against it adding -static to the cc command, you might want to check my spidermonkey-config example script and the GNUMakefile (made for GNU make): (spidermonkey-config is in util/ and GNUMakefile into src/) http://cvs.pulsar-zone.net/cgi-bin/cvsweb.cgi/mmondor/tests/js-test/ Basically, spidermonkey-config is a helper script for makefiles which can report the proper CFLAGS and/or LDFLAGS: --- (ttyp4) mmondor@hal.xisop $ spidermonkey-config Usage: spidermonkey-config [-v] [-c] [-l] [-d] -v : Shows SpiderMonkey version -c : Shows flags suitable to append to $CFLAGS -l : Shows flags suitable to append to $LDFLAGS -d : Shows debugging versions of the flags --- (ttyp4) mmondor@hal.xisop $ spidermonkey-config -cl -I/usr/local/spidermonkey/include -DXP_UNIX -Wl,-R/usr/local/spidermonkey/lib -L/usr/local/spidermonkey/lib -ljs --- (ttyp4) mmondor@hal.xisop $ A similar system should work on most unix systems (used this on NetBSD and Linux so far). Hope this helps, Matt -- Note: Please only reply on the list, other mail is blocked by default. Private messages from your address can be allowed by first asking. .