Better Know a Virtual Machine - SquirrelFish Edition
Tuesday, January 6, 2009 at 8:32PM I've probably spent more time than I should reading Digg/reddit. While Digg is always thoroughly entertaining, reddit is more thought provoking. One things that comes up often on reddit is something related to compilers. Even when I was taking intro compiler courses, my advisor Michael Franz said every book is pretty outdated or overly complex. The best resource online I could find was people in forums or WikiBooks - Compiler Construction. Both are severely lacking. So to help everyone out there, I'm going to start a new series called "Better Know a Virtual Machine", just like Stephen Colbert's "Better Know a District". This series is also a way for me to learn about VMs and spit out what I learned in my adventures. I'm going to be starting with SquirrelFish Extreme (SFX) since it's so freaking fast. Bravo SquirrelFish team.
- Download the developer tools following the WebKit Instructions. Install SP1 for Visual Studio 2005 Team Edition even if you have professional. Use the WebKit SP1 link.
- When you install cygwin, make sure you add the packages 'curl' and 'unzip'. Also, even if you have cygwin installed, don't skip the cygwin part. I solved a lot of random problems by starting from scratch and using their cygwin distro.
- You don't need the Quicktime SDK if you only want to build SquirrelFish.
- Checkout the source code following the WebKit instructions. Twiddle thumbs.
- Load up cygwin and update the WebKit source code from the trunk using the update-webkit script. You HAVE TO DO THIS, even if you just checked out. Begin whistling.
- Unzip the WebKit Support Libraries to {WebKitRoot}/WebKitSupportLibrary.
- Add the cygwin '/usr/bin' utilities to your Windows PATH. The cygwin location for these programs is {cygwin installation}/bin.
- Create the directory "WebKitOuputDir" in the WebKit directory.
- Set the Environmental User (NOT SYSTEM) Variable for the WebKit build result binary location. When I set it to something custom, it totally fubared. Set variable name "WebKitOutputDir" to "{WebKitRoot}\WebKitBuild". All the scripts/visual studio solution assume its there.
- Set the Environmental User (NOT SYSTEM) Variable for some WebKit libraries. Set the "WebKitLibrariesDir" to "{WebKitRoot}\WebKitLibraries\win". Make sure you add the win. Boy oh boy did that take a lot of digging to figure out.
- Double click the Visual Studio Solution in {WebKitRoot}\JavaScriptCore\JavaScriptCore.vcproj\JavaScriptCore.sln.
- We need to add some include libraries for WebKit to build. First stdint.h! Go to tools->Options->Projects and Solutions->VC++ Directories. Change the "Show Directories For" to "Include Files".
- Add the following directories. Use the full paths:
- {WebKitRoot}\WebCore\icu
- {WebKitRoot}\WebKitSupportLibrary\win\include
- {WebKitRoot}\WebKitLibraries\win\include
- {WebKitRoot}\WebKitLibraries\win\include\pthreads
- {WebKitRoot}\JavaScriptCore\os-win32
- Change the "Show Directories For" from "Include Files" to "Library Files". Add the following directories:
- {WebKitRoot}\WebKitLibraries\win\lib
- Pray you don't have any errors, change the build configuration to Release, and push the build button. You can ignore the warning "Variable ${Production} isn't defined".
- The result should be in {WebKitRoot}\WebKitBuild\bin\jsc.exe.
- ???
- PROFIT! You can stop screaming at the monitor now.
- icudt36.dll
- icuuc36.dll
- pthreadVC2.dll
print("WEEEE!");
1) There is no stdint.h, pthreads.h, or unicode/something.h!
Check that the the global VC++ settings (tools->options->Projects and Solutions->VC++ Directories) included these directories in the "include files". path. These directories are not for specific projects, but global Visual Studio VC++ paths. If you're missing:
- stdint.h -> add {WebKitRoot}\JavaScriptCore\os-win32
- pthreads.h -> add {WebKitRoot}\WebKitLibraries\win\include\pthreads
- unicode/something.h -> add {WebKitRoot}\WebCore\icu
- CoreFoundation -> add {WebKitRoot}\WebKitSupportLibrary\win\include
This means that one of these dlls isn't in your PATH. Create a new directory and dump this dll in that directory. Add the newly created directory to your PATH. I did a search on my system and found that the .dll was included with the Safari binary that is with the official Safari release. Or you can just add the whole Safari directory into your PATH.
3) When the project "jsc" is compiling, I get a bunch of linker errors that are something like this: WTF.lib(CollatorICU.obj) : error LNK2001: unresolved external symbol _ul_open_3_2
Out of the blue, it means that the Environmental Variable "WebKitLibrariesDir" wasn't correctly set. Who would've thunk. Check to ensure that this points to the correct location. I need to find out why there is a Visual Studio project called "WTF" :).
4) I get the compilation error complaining about "icuin.dll" missing.
The WebKitLibraries library path isn't added within visual studio. Add the "{WebKitRoot}\WebKitLibraries\win\lib" directory to the VC++ included library path.
Change the build configuration from "debug_internal" to either debug or release.
7) Should I waste my time trying to build SquirrelFish on Visual Studio 2003/2008?
Sure be my guest! It's not supported and I wasted two days of my life trying to get VS 2008 working. If you can figure out how to do it, please tell me!
* I deleted all of my setup changes from when it first worked and followed these steps. I may have missed something. If so, please let me know and I'll add it.

Reader Comments (2)
Thank you, sir!
This was incredibly helpful when building all of Webkit on Windows, not just SquirrelFish.