dogman1 has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I've run into a problem that seems specific to installing the Javascript.pm module.

I am trying to install the Javascript module from CPAN: here. I have Windows XP and use strawberry perl, so I used the CPAN client to install, but I run into some errors.

When the makefile.pl runs, it prompts me for some questions about spidermonkey. Then it returns some messages that says it can't locate some files. Here's what I get:

C:\strawberry\cpan\build\JavaScript-1.12-M_rctc>perl makefile.pl Is your SpiderMonkey compiled with JS_THREADSAFE (most things will fai +l if you answer wrong)? [y/N] Is your SpiderMonkey compiled with support for unicode (t/23-unicode.t + will fail if you answer wrong) ? [y/N] [N] N Do you want support for E4X (requires SpiderMonkey > 1.5) ? [y/N] [N] +N In file included from test_js.c:2: JavaScript_Env.h:8:19: error: jsapi.h: No such file or directory JavaScript_Env.h:9:22: error: jsdbgapi.h: No such file or directory JavaScript_Env.h:10:22: error: jsinterp.h: No such file or directory JavaScript_Env.h:11:19: error: jsfun.h: No such file or directory JavaScript_Env.h:12:19: error: jsobj.h: No such file or directory JavaScript_Env.h:13:19: error: jsprf.h: No such file or directory JavaScript_Env.h:14:21: error: jsscope.h: No such file or directory Failed compiling test_js.c. ABORTING

These files are located in my C:\strawberry\js\src directory. The js32.dll file from building spidermonkey is also there too in a subfolder. I tried moving the files into the Javascript-1.12-M_tcrc directory, but I still get the same problem. I tried to read the makefile.pl but I'm pretty new to perl and don't understand what the code does.

My guess is the files are in the wrong location, but I don't know where to put them to make makefile.pl work. Thanks for the help.

Replies are listed 'Best First'.
Re: Installing Javascript.pm on XP
by syphilis (Archbishop) on Aug 05, 2009 at 02:03 UTC
    My guess is the files are in the wrong location

    There's nothing wrong with leaving them where they are, but the Makefile.PL needs to be able to find them.
    Going through the Makefile.PL, it looks as though you can tell the Makefile.PL process most (if not all) of what it needs to know by setting environment variables - eg set the JS_INC environment variable to the location of the missing header (.h) files, and the JS_LIB environment variable to the location of the javascript library (.a) files.

    Specifying INC and LIBS on the command line, as already mentioned by Anonymous Monk, might also work - though I can't be sure that the Makefile.PL won't clobber information that's being passed along by that method.

    Cheers,
    Rob

      Hey, thanks for the responses.

      I went into Makefile.PL and manually edited the JS_INC and JS_LIB keys in the %ENV hash to the correct folders. Also it was originally giving me "-ljs", and I changed that to "-ljs32" Now when I run Makefile.PL it returns this to the command prompt:

      gcc -LC:\strawberry\js\src\WINNT5.1_OPT.OBJ -ljs32 -o C:\DOCUME~1\Steve\LOCALS~1\Temp\UCzBT5mwxB -IC:\strawberry\js\src test_js.c

      jsapi.h and other .h files are located in C:\strawberry\js\src
      js32.lib is located in C:\strawberry\js\src\WINNT5.1_OPT.OBJ

      Now it seems to know where the files are, but it's giving me a looong list of errors and warnings. Too long to copy all of it on here but here's a sample

      In file included from JavaScript_Env.h:17, from test_js.c:2: C:/strawberry/js/src/jsxml.h:59: error: field `declared' declared as a + function C:/strawberry/js/src/jsxml.h:110: error: `JSIdentityOp' declared as fu +nction returning a function C:/strawberry/js/src/jsxml.h:164: error: syntax error before "uint16" C:/strawberry/js/src/jsxml.h:164: warning: no semicolon at end of stru +ct or union C:/strawberry/js/src/jsxml.h:165: warning: data definition has no type + or storage class C:/strawberry/js/src/jsxml.h:178: error: conflicting types for 'u' C:/strawberry/js/src/jsfun.h:65: error: previous declaration of 'u' wa +s here C:/strawberry/js/src/jsxml.h:181: error: syntax error before '}' token C:/strawberry/js/src/jsxml.h:254: error: `js_GetFunctionNamespace' dec +lared as function returning a function C:/strawberry/js/src/jsxml.h:257: error: `js_GetDefaultXMLNamespace' d +eclared as function returning a function C:/strawberry/js/src/jsxml.h:260: error: `js_SetDefaultXMLNamespace' d +eclared as function returning a function C:/strawberry/js/src/jsxml.h:268: error: `js_IsXMLName' declared as fu +nction returning a function C:/strawberry/js/src/jsxml.h:271: error: `js_ToAttributeName' declared + as function returning a function C:/strawberry/js/src/jsxml.h:287: error: `js_GetAnyName' declared as f +unction returning a function C:/strawberry/js/src/jsxml.h:290: error: `js_FindXMLProperty' declared + as function returning a function C:/strawberry/js/src/jsxml.h:293: error: `js_GetXMLProperty' declared +as function returning a function C:/strawberry/js/src/jsxml.h:296: error: `js_GetXMLFunction' declared +as function returning a function C:/strawberry/js/src/jsxml.h:299: error: `js_SetXMLProperty' declared +as function returning a function C:/strawberry/js/src/jsxml.h:302: error: `js_GetXMLDescendants' declar +ed as func tion returning a function C:/strawberry/js/src/jsxml.h:305: error: `js_DeleteXMLListElements' de +clared as function returning a function C:/strawberry/js/src/jsxml.h:308: error: syntax error before "jsbyteco +de" C:/strawberry/js/src/jsxml.h:308: error: `js_FilterXMLList' declared a +s function returning a function C:/strawberry/js/src/jsopcode.h:239: warning: array 'js_EscapeMap' ass +umed to have one element

      I think all the header files are causing errors.

        Best to show us the *first* error (and the pre-amble leading up to it), as that's the important part. All other errors are often just a follow-on effect that is fixed when the first error is fixed.

        Cheers,
        Rob
Re: Installing Javascript.pm on XP
by Herkum (Parson) on Aug 05, 2009 at 03:27 UTC

    The nice thing about Strawberry is that you can use ppm to install modules. Try using that and hope that someone has already compiled the module.

      Yes - and it *is* available from the bribes repository:
      ppm install http://www.bribes.org/perl/ppm/JavaScript.ppd
      Cheers,
      Rob
        yes but the repo bribes is not for 5.12 on win32. Update possible?
      I was under the imression that an important aspect of Strawberry Perl was to free Windows users from having to rely on pre-compiled modules?

      Not saying that using ppm is "wrong" or anything, just curious.

      -- Time flies when you don't know what you're doing
        I was under the imression that an important aspect of Strawberry Perl was to free Windows users from having to rely on pre-compiled modules?

        It is. The problem, SpiderMonkey doesn't build easy on win32/mingw, there are no binaries available, and you can't build JavaScript without SpiderMonkey.

Re: Installing Javascript.pm on XP
by Anonymous Monk on Aug 05, 2009 at 01:30 UTC
    Assuming C:\strawberry\je\js32.lib (or js32.a) and C:\strawberry\js\src\jsapi.h, try
    perl Makefile.PL INC=-IC:\strawberry\js\src LIBS="-LC:\strawberry\js +-ljs32"
Re: Installing Javascript.pm on XP
by Anonymous Monk on Aug 05, 2009 at 07:28 UTC
    Where did you get SpiderMonkey?

      Addressing some of the comments:

      - The long list of errors was caused by one of the first errors as syphilis said. Makefile.PL was outputting '#define XP_PC' to Javascript_Env.h, and the first error said that I needed to define "XP_BEOS, XP_OS2, XP_WIN, or XP_UNIX". So I changed 'XP_PC' in Makefile.pl to 'XP_WIN' and now I only get this.

      C:\strawberry\cpan\build\JavaScript-1.12-mJTECJ>perl Makefile.pl Set up gcc environment - 3.4.5 (mingw-vista special r3) C:\DOCUME~1\Steve\LOCALS~1\Temp/ccciHYlf.o:test_js.c:(.text+0x2b): und +efined reference to `JS_GetImplementationVersion' collect2: ld returned 1 exit status Failed compiling test_js.c. ABORTING

      - I built SpiderMonkey 1.7 following the instructions here. I first downloaded the Mozilla Build environment and Visual C++ 9. Then I used the start-msvc9.bat in the mozilla-build folder (I think this is minGW) and followed the instructions on the web page to build the optimized/non-debug Spidermonkey. I think it worked as there is a shell (js.exe) in the ../jd/src folder that can read print("Hello world").

      I stopped using minGW because when I tried to run Makefile.pl I was prompted that I needed perl version 5.8 and minGW only had 5.6.1 or something. So I'm now just using the windows command prompt.

      - Finally, I tried the Javascript.pm from the repository and it seems to work great. I needed it for another module that was dependant on Javascript.pm. I guess that is problem solved, but I'd still be curious about getting it right the hard way.

      Thanks for the help.

        Please send me a patch with what you needed to change in order to get it to work on Windows and I'll integrate it.

        preferably against the git repo http://github.com/claesjac/javascript.git

        Cheers,
        Claes

        I stopped using minGW because when I tried to run Makefile.pl I was prompted that I needed perl version 5.8 and minGW only had 5.6.1 or something. So I'm now just using the windows command prompt.

        I can't make much out of that. It sounds like perl-5.6.1 was found, but perl-5.8.x is needed - however, that would have nothing to do with MinGW (or any other compiler).

        When you ran 'perl Makefile.PL' which version of perl was being run (running 'perl -v' will tell you) ? Do you have more than one perl installed on your machine ?

        Also, the actual output of 'perl Makefile.PL' might help us determine the problem and solution.

        Cheers,
        Rob