I successfully compiled spidermonkey (on windows), how can I link against it now (to embed it)?
js-config is not properly installed, and I don't understand this workaround.
Linking to the static library should be easier, but I don't even know which file it is. I have mozglue.lib, mozjs-43a1.lib, nspr4.lib, plc4.lib, plds4.lib
in dist/sdk/lib
and nspr4.lib, plc4.lib, plds4.lib
in dist/lib
.
Update
js-config
was not working because I had this problem (-bash: '\r': command not found
because of Windows/Unix newline characters problem, I ran dos2unix js-config
and I could run it).
However, the output does not help (on windows):
$ ./js-config --cflags
-std=gnu++0x -include /usr/local/include/mozjs-43a1/js/RequiredDefines.h -I/usr/local/include/mozjs-43a1 -Ic:/Users/Yvain/Documents/mozilla-central/js/src/build_OPT.OBJ/dist/include/nspr
$ ./js-config --libs
${libdir}/${JS_LIBRARY_NAME}.lib c:/Users/Yvain/Documents/mozilla-central/js/src/build_OPT.OBJ/dist/lib/nspr4.lib c:/Users/Yvain/Documents/mozilla-central/js/src/build_OPT.OBJ/dist/lib/plc4.lib c:/Users/Yvain/Documents/mozilla-central/js/src/build_OPT.OBJ/dist/lib/plds4.lib kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib psapi.lib
Notes
I used the following command to compile:
g++ -std=c++11 -I<objdir>/dist/include -L<objdir>/dist/lib helloworld.cpp -o helloworld -lmozjs-31 -lz -lpthread -ldl
I know it is not the correct way to compile it since those libraries are not in <objdir>/dist/lib
. It returns the following errors:
[...]/jscpucfg.h:121:3: erreur:
#error "Cannot determine endianness of your platform. Please add support to jscpucfg.h."
[...]
erreur: ‘JS_EvaluateScript’ was not declared in this scope
This question seems to draw some attention. Note that I asked the same question for V8.
The idea behind the work around is to run js-config --libs and put the result in JSAPI_LD_FLAGS, possibly filter out things on Darwin, and then append JSAPI_LD_FLAGS to your LDFLAGS so you can link the right libraries.
So for your library question, the answer is to get js-config built and then run it with --libs
Likewise, you would create your CFLAGS using a combination of the CFLAGS you need already and the output of js-config --cflags
. This is something you may have already found yourself doing with the nifty pkg-config utility for other libraries.
This doesn't solve the endianness problem. Why don't you just run the configure script?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With