while($alive) LiveAndLearn();

JavaScript, PHP, C# and Life in Viet Nam

SpiderMonkey Solution File for Microsoft Visual Studio 2005

with 32 comments

Lately I have experimented a bit with SpiderMonkey, the C implementation of the JavaScript engine used in Mozilla’s browsers, and it took me some time before I got it to work without changing the code. In the beginning I used the makefile, but found that it would be a lot easier if I could open the project as a solution in MS Visual Studio 2005.

Unfortunately I didn’t have any luck Googling for a solution file for MS Visual Studio 2005, I saw someone suggested using the js.mdp-file which is included when you checkout the SpiderMonkey project from Mozilla’s CVS server, but my version of MS VS 2005 wasn’t able to convert it, announcing that the project file was corrupt.

I thought there might be others out there having similar problems with their SpiderMonkey-build so I decided to write this post, hoping that I can help others getting started, and perhaps someone with more experience can help me make my solution file and project files better as it is the first time I have created handmade project files for C/C++ projects in MS VS 2005 so I might have made some mistakes along the way.

I have also modified the make file because some of the compiler options are deprecated and others should be used instead. But let’s get started, this post will let you know how to checkout SpiderMonkey and get started using my solution file and project files. I assume you already have an CVS client installed like Tortoise CVS which is the one I am using.

To check out SpiderMonkey the easiest thing is to follow the guidelines for check out which can be found here. I checked out the version tagged MOZILLA_1_8_BRANCH. Maybe you have more luck than I did following the included build documentation, but I was tossed around a bit before I found out that the makefile you really need is called js.mak if you want to build with VC8.

I checked out from Mozilla’s CVS server using the following commands:

cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot login
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -l -r MOZILLA_1_8_BRANCH mozilla/js/src mozilla/js/src/fdlibm
cvs -d :pserver:anonymous@cvs-mirror.mozilla.org:/cvsroot co -l mozilla/js/src/config mozilla/js/src/editline

Once you have checked out the version to your computer open a command prompt and execute the batch-file called vcvarsall.bat to get the MS VS 2005 environment variables registered.

vc variables SpiderMonkey Solution File for Microsoft Visual Studio 2005

Now the C++ compiler and linker will be available from this command prompt, you can also choose to set it up more permanently, this is just the way I did it. Change path to the location of the files you just checked out from Mozilla’s CVS server, you should now try to build the project using nmake.

first jsmak build SpiderMonkey Solution File for Microsoft Visual Studio 2005

I didn’t include all the build information for as you can see I ended up with a linker error. Googling a bit on the subject I found out that this can be solved by including jsiter.c in the jsinterp.c file, but I really didn’t like to change anything in the code unless I had to, so I saw yet another reason for trying to make a solution file which wouldn’t produce any linker error.

Using the makefile I got a lot of warnings about deprecated option settings so I decided to follow some of the advice the compiler gave me to produce a make file more suited for MS VS 2005, furthermore I change a little bit in some of the dependencies for building and I was able to remove the linker error without changing any files at all. What I did was to include the jsiter.obj file when building the js32.lib which gave the linker the necessary references.

Using my updated makefile I was able to build the project, and because some of the functions used are deprecated according to the VC8 compiler I added the two preprocessor commands /D “_CRT_SECURE_NO_DEPRECATE” and /D “_CRT_NONSTDC_NO_DEPRECATE” as well. You can download my makefile from here.

second jsmak build SpiderMonkey Solution File for Microsoft Visual Studio 2005

After running the make you should now be able to start the JavaScript shell which is included in the checkout using Debug\jsshell.exe from the current path in the command prompt.

running jsshellexe SpiderMonkey Solution File for Microsoft Visual Studio 2005

Great so far so good, but what I really wanted to use MS VS 2005, so I still had some work to do. Based on the makefile I created four projects for the solution, the four projects are:

  • fdlibm - This project is needed for mathematical operations as far as I have been able to figure out
  • js32 - This project is the JavaScript engine itself, here the API for embedding the JavaScript engine into your own applications is defined.
  • jskwgen - This project I created in order to make the header-file called jsautokw.h which is a prerequisite for building the js32 project, basically it contains a big switch-block with, what appears to be, all JavaScript keywords which can be found in the file jskeyword.tbl.
  • jsshell - This project contains the files for creating the interactive JavaScript shell which can be used to execute JavaScript either inputted through the shell or loaded from an external file.

The hardest work was to get all the compiler settings right using the makefile as my only reference, I did omit some settings, and some of them might be important, but none the less I ended up with a solution file which allows me to build SpiderMonkey directly from MS VS 2005 which was my intention. If I make any updates to the solution file I will announce it in another post.

If anyone out there reads this post and can help me improve on this solution file then you are more than welcome. Also if you have any questions or comments to my post I would like to hear from you, I might be able to answer.

If you wish to have a look at my solution files then you can find them here. I made it available on Google Code as an archive maintaining the path from Mozilla repository, so you should be able to copy the top directory directly from the archive to the location of your check out from CVS.

share save 171 16 SpiderMonkey Solution File for Microsoft Visual Studio 2005

Written by Thomas Bindzus

February 8th, 2008 at 7:27 pm

32 Responses to 'SpiderMonkey Solution File for Microsoft Visual Studio 2005'

Subscribe to comments with RSS or TrackBack to 'SpiderMonkey Solution File for Microsoft Visual Studio 2005'.

  1. You should use Makefile.ref (not the js.mak file), with GNU make (not nmake). The MozillaBuild package contains these items. It will build a native js shell and library file that you can use, using your installed (and PATH’d) cl.exe

    E-mail me if you have trouble with this,
    crowder

    Brian Crowder

    10 Feb 08 at 01:26:17

  2. Rather, Makefile.ref will come with the js/src checkout from CVS. GNU make is included in the MozillaBuild package.

    Brian Crowder

    10 Feb 08 at 01:28:12

  3. You couldn’t have written this at a more apt time (at least for me). I’ve used your files to create project files for VC2008, which is great for my JS Neko wrapper I’m currently working on. Until now, I’ve had to suffer using the debug version of SpiderMonkey only, as I couldn’t work out how to compile a release version through nmake… :-S

    Thanks again!

  4. Thanks a lot for these files! You just saved me a lot of time.

    Drew

    11 Mar 08 at 05:12:48

  5. Hi,

    very good job, thanks a lot!

    I recognized that jskwgen must not depend from
    any other project and fdlibm.lib should be
    removed as explicit input to jsshell in release
    mode since it is included already via the
    project dependency.

    Feel free to email me if I should send you the
    corrected files.

    Bye,

    Roland

    Roland

    18 Mar 08 at 19:03:41

  6. Thank you so much for commenting on my entry. I was not sure whether anybody would be interested, but I am glad I was wrong.

    Thank you Roland for sending me updated project files! I have added solution file and project files under Subversion control on Google Code, so you should be able to get updated versions from there.

    The rar-package is NOT up-to-date yet since Google Code claims I don’t have permission to upload the new files, but I will have a new package up as soon as possible for those who do not wish to checkout the files using Subversion.

    Thomas Bindzus

    18 Mar 08 at 20:02:16

  7. Thank you very much, couldn’t have found this at a better time.

    As an aside, fancy uploading everything as a zip rather than a rar?

    Rick Taylor

    3 Apr 08 at 19:09:02

  8. Hey, thanks a bunch! I was getting discouraged trying to do this myself. Your projects work great! I’m humming along now with embedded JS…

    pmd

    9 May 08 at 05:23:14

  9. Thanks a lot. I have done a couple of these conversions with other packages and they take a lot of work. Thanks for doing it and mostly taking the time to post it….

    charp

    15 May 08 at 23:28:21

  10. Too cool. Thx, Tom

    Tom Phan

    18 Jun 08 at 02:47:03

  11. Hi,
    Your post and the Makefile provided are very helpful.
    I would like to know, have you tried to generate a project/lib for Vxworks platform?

    More specifically, How do I generate the jskwgen.h dynamically on VxWorks?

    Mantu

    2 Jul 08 at 21:50:29

  12. Thanks great tool very hepfull

    Serkan

    11 Jul 08 at 20:18:22

  13. Hi I have copied your vc solution in vc++ 2008
    it give the following error message

    1>—— Build started: Project: jskwgen, Configuration: Debug Win32 ——
    1>Linking…
    1>LINK : D:\SpiderMonkey\SpiderMonkey\Debug\jskwgen.exe not found or not built by the last incremental link; performing full link
    1>Embedding manifest…
    1>Performing Post-Build Event…
    1>Build log was saved at “file://D:\SpiderMonkey\SpiderMonkey\Debug\BuildLog.htm”
    1>jskwgen – 0 error(s), 0 warning(s)
    2>—— Build started: Project: js32, Configuration: Debug Win32 ——
    2>Compiling…
    2>jsscan.c
    2>.\js32\c\jsscan.c(112) : fatal error C1083: Cannot open include file: ‘jsautokw.h’: No such file or directory
    2>Build log was saved at “file://D:\SpiderMonkey\SpiderMonkey\Debug\BuildLog.htm”
    2>js32 – 1 error(s), 0 warning(s)
    ========== Build: 1 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

    any idea??
    Thaks in adavance

    Li

    16 Jan 09 at 17:23:39

  14. Hi Li, I haven’t yet tried to use my vc solution with vs2008, so I am afraid I do not have an answer for you, however there might be some other readers who have a solution? If I get time I will try to see if I can get it to work with vs2008 in the near future.

    Thomas

    Thomas Bindzus

    29 Jan 09 at 14:44:11

  15. Thomas,

    Do you have VS2008 solution file? I am looking for the same and ran into your post.

    Kumar.

    Kumar Mettu

    17 Mar 09 at 06:26:59

  16. Got it working with VS2008.

    Kumar Mettu

    19 Mar 09 at 04:23:03

  17. Hi Kumar, that was fast ;) would you mind sharing? As you can see Li had some problems as well, and I have been too busy to work with SpiderMonkey lately :(

    Thomas

    Thomas Bindzus

    19 Mar 09 at 13:53:17

  18. Good work publishing that VS solution file, I’ve just used it to build Spidermonkey 1.8 RC1 in VS 2005 with a couple of minor tweaks.

    I just thought I’d post an update in case it’s useful for anyone else.

    Download the spidermonkey source archive (js-1.8.0-rc1.tar.gz) and extract. Install Thomas’s VS solution files from SVN repository in the same dir and load the Spidermonkey.sln.

    Add jsinvoke.c to the JS32 project (otherwise I got link errors about js_FreeStack etc).

    Edit the JS32 project properties, go to Linker|Input and add winmm.lib to the Additional Dependencies otherwise I got linker errors about timeEndPeriod.

    Build it all and you should have the JS32.dll in the debug dir.

    Cheers,

    Colin

    Colin Fraser

    10 Apr 09 at 17:17:57

  19. Thomas, thanks.

    For anyone else interested in later versions of VC++,
    I have posted a .ZIP containing a VS 2008 solution file plus a snap of the 1.80 RC1 source code here: http://www.novadsp.com/code

    All project files have -08 appended to avoid confusion. Build and then run the ready-baked jsshell-08 to get an interactive JS console app.

    Jerry

    16 Jun 09 at 01:03:26

  20. Thanks Jerry, I never got around to get it done :-)

    Kind regards
    - Thomas

    Thomas Bindzus

    16 Jun 09 at 09:18:41

  21. Thank you very mach for this solutions!
    It is works well now on vs2008ee.
    Good luck!

    alex_k

    18 Aug 09 at 16:10:38

  22. Following Colin Fraser’s post above I was also able to get VS 2005 compiling, but I did require one additonal change.

    The Release linker settings were pointing to fdibm.lib file, but the linker path was not set properly. Simply removing the fdibm.lib in the linker settings allowed the project to compile.

    Joe Chen

    9 Oct 09 at 03:33:49

  23. Hello, I’ve just built SpiderMonkey 1.8.0rc1 using Visual C++ 2008, came here from google but the only thing that helped was reading the Makefiles. Brian Crowders comments about Makefile.def were most useful.

    My notes are here: http://spidey01.blogspot.com/2009/12/building-spidermonkey-180-rc1-on.html

    TerryP

    29 Dec 09 at 04:14:52

  24. Hi there, my objective was not to create a makefile that would build SpiderMonkey, my objective was to create a solution file for VS, so I could build SpiderMonkey from the IDE :-)

    Thanks for your reference, it’s included for everyone that wants to build SpiderMonkey using the makefile, which is also very useful :-)

    Thomas Bindzus

    29 Dec 09 at 08:17:11

  25. Dear Thomas Bindzus,

    I have built the VS 2005 and 2008 sln’s. Running the jsshell produces a window with “js>” prompt. Writing a script file in this window should basically execute the script right!!?? for eg: document.write(“hello”); on this window should produce “hello” on this screen. This is not happening. Would you kindly explain the working of jsshell and if I am doing it correctly!!! thank you

    coder

    23 Jun 10 at 18:16:15

  26. Hi Coder, document is part of the DOM which the browser enables you to access through JavaScript. The DOM is not available from the jsshell as it only supports core JavaScript. If you call the function help(), then you can see the special functions available from the jsshell. The function print can be used for output.

    Thomas Bindzus

    23 Jun 10 at 22:50:18

  27. @Jerry: Thanks for sharing. You helped me a lot :D

    anhldbk

    24 Mar 11 at 11:37:47

  28. in your solution file(1.7) I had seen that for fdidm and jsshell you had used the /MD option.but in js32 and jskwgen you used /MT.
    Will not cause this any problem to your solution file(after compilation).

    parveen

    20 May 11 at 11:38:51

  29. I didn’t experience any problems at the time, it might have some consequences I’m unaware of, seems I should have switched them around right?

    Thomas Bindzus

    21 May 11 at 13:49:05

  30. I have successfully compiled the version of Jerry with Visual Studio 2010. I also managed to get a successfully compilation of a 64 bit version. The steps to reach this I want to share:
    I created a new x64 configuration as a copy of win32. Then I had to change the preprocessor define of the js32-08-project by deleting “_X86_=1″ and adding “_AMD64_=1″. Beforehand I added “MachineX64 (/MACHINE:X64)” under “Linker->advanced->Target Machine” . I also had to adjust the name from fdlibm.lib to fdlibm-08.lib.

    Does anyone here has experience with 1.8.0 RC1 as 64-bit Version?

    FrankO

    8 Nov 11 at 21:46:42

  31. can any one build the 1.8.5 with VS2008 IDE . I am trying to build . endu up with numerous errors.

    mahesh

    14 Feb 12 at 11:45:44

  32. hi

    iamm trying to build 1.8.5 in VS2008. and i have added all files to project i.e. files in nanojit , methodjit and and all source files
    with following preprocessor definations _DEBUG
    _WINDOWS
    _USRDLL
    JS32_EXPORTS
    EXPORT_JS_API
    XP_WIN
    JS_CPU_X86
    JS_NUNBOX32
    __STDC_LIMIT_MACROS
    JS_TRACER
    TRACEING
    USE_SYSTEM_MALLOC
    ENABLE_ASSEMBLER
    ENABLE_JIT
    AVMPLUS_IA32
    DEBUG
    JS_METHODJIT
    JS_MONOIC
    AVMPLUS_WIN32
    FEATURE_NANOJIT

    but stll iam facing issue when compiling the source fatal error C1083: Cannot open include file: ‘sys/mman.h’: No such file or directory

    mahesh

    16 Feb 12 at 13:22:13

Leave a Reply

Switch to our mobile site