Archive for February 2008
The Solution to all Power Failures?
This is definitely weird, I still have to question whether it’s unimportant or not. The truth is it has kept me awake for almost an hour now watching all 7 parts of it. It started very innocently with me paying a visit to Scott Adams’ blog and read this post about a guy who have apparently invented a very interesting motor. Judge for yourself but I would sure like to see some more solid evidence before I am 100% convinced, but it’s definitely interesting.
SpiderMonkey Solution File for Microsoft Visual Studio 2005
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.

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.

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.

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.

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.
First Day in The Year of the Mouse
Today we went downtown (district 1 in Ho Chi Minh City) to see all the beautiful flowers arrangements setup on Nguyen Hue Street. We arrived around 2 PM and found the whole street blocked for motor vehicles. I panicked a bit because I don’t usually have to park downtown and wasn’t quite sure where we could get rid of the bike.
We continued down Dong Khoi Street which runs parallel to Nguyen Hue all the way down to the river continued along the river past Nguyen Hue Street and there we found parking arrangements made for motorbikes. After getting rid of the bike our Mary, Nhi, my wife and I was ready to look at some flowers.
Nguyen Hue Street is probably one of the widest streets in inner city with a lot of office buildings lying on each side of the street, Sun Wah Tower is actually the only one I can come to think of right now because that is where the Danish Chamber of Commerce is located which also handle visa applications for entry to Denmark. Of course there are also some rather expensive hotels and pretty good restaurants on this street and the Saigon Tax Trade Center where we usually buy our movie DVDs, good quality low price (13.000 VND per DVD).
When we first entered the street we saw a ship setup in the middle of the street with flowers for sail. Nguyen Hue Street has 3 lanes in each direction one of the lanes is separated from the others with around a meter wide piece of green grass with trees. In each directions flowers were put up on each side of the two remaining lanes making room for bigger arrangements in the middle of the street. It’s kind of difficult to explain exactly how it looked so I took the photo below, hope it helps imagining how it looked.
There really was a lot of flowers it was quite amazing to see how much was put up, very creative and lots of different themes. Further down the street were islands with flowers, we saw an arrangements with a small lake and a monkey bridge across it, we didn’t try it though because there were people on it all the time, and I guess Mary is not yet that steady on her legs even though she did pretty well, walking on her own two most of the time.
Anyway short post about one of the traditional things (at least this year and last year) that happens during the Tet (Vietnamese for Lunar New Year) just felt like sharing some of the photos I took today, some more photos follow below.
Some of the arrangements contained mice since it is the year of the mouse (or the rat) we have just entered, so at the opposite end of Nguyen Hue Street we found the mouse family.
My favorite kind of flower is orchids and there were also a lot of orchids to look at, like in the arrangements shown below.
After reaching the other end of Nguyen Hue Street we paused for a cold drink at a café put up outside the Saigon Tax Trade Center for the occasion.
Lunar New Year Eve
So yesterday (06-02-2008) was Lunar New Year eve and we were at home waiting for 12:00 PM where we would welcome the year of the mouse (or rat) with a table set up for Buddha with fruit, rice and candles right outside our front door praying for good luck in the year to come.
We also had the TV on so we could see the fireworks at 12:00 PM, experience had taught me well, I had no intention of taking the bike around downtown again any time soon, just sitting at home enjoying the show from our couch would be more than enough for me.
Then at 10:30 PM the power went out, that’s just great, definitely the right evening to be without power, NOT!
We got a hold of our battery powered lights and even lit up some candles my preferred light source when the power goes to some other countries for a while, well that is at least how I imagine it, because I have heard that Vietnam is selling power to some of their neighbor countries, which is great when they can’t even supply Vietnam with enough power, but after a while you get use to it
The power failures also keep reminding me of Philip because almost every time I read his blog he has a post about yet another power failure in his area in the US (Southern California) and he do tend to mention the power failures he experienced during his time in Vietnam, pretty funny.
During the power failure we noticed that one of our fish started to act weird, swimming up-side-down, I don’t really know what has happened to it, but it hasn’t really been its true self since yesterday, it’s like it has been paralyzed from the middle and down to the tail.
Luckily the power was back again 11:40 PM so plenty of time to make last preparations and get the TV tuned in to the right channel for fireworks, the kids ran upstairs to try and get a glimpse of the firework downtown but Tan Binh is pretty far from district 1, so actually we didn’t get much besides the sound.