Compiling
WebKit on Windows is far from trivial. In the process of getting it compiled and linked successfully, I took some notes which may help others struggling to getting it done.
First, a few precautions, don’t try to be smart. Follow the instructions on the site closely, this means:
- Don’t try to compile w/ Visual C++ 2008, it won’t work. Use VC++ 2005.
- For VC++ 2005 Express Ed., make sure you have SP1, compilation will fail w/o it.
- For Vista, make sure you have the additional SP update.
- Don’t try to compile outside of cygwin directory structure.
Next, you need to get the webkit source.
- Get the source from a nightly build (make sure to download the source and not one of the platform specific builds). You can also get the files from the subversion repository, but I had issues with this and discovered missing files. It may have been fixed, but in general, I think just getting the nightly build is simpler.
- The source is in a .bz2 file. So you’ll need a bzip2 decompressor.
- The bz2 file decompresses to a .tar file (wtf?!), so you’ll also need a tar decompressor.
- Next, download the WebKit Support Libraries.
- Put the source under your cygwin/home/<username> directory (e.g. \cygwin\home\<username>\WebKit)
- Finally, update, by running the update-webkit script.
Preparing for compilation.
Note: I tried to build from the cygwin shell, as demonstrated on webkit.org, but it failed. Failing in this way and then having to dig thru build logs is insane, so I diverted to building from within VC++ so I could easily spot and fix errors as they occurred.
Note: I failed to realize that I didn’t have SP1 for VC++ 2005 Express when I started this whole process and didn’t figure it out until I hit a few perplexing errors related to the linker failing because it detected different versions of the compiler were used for the 2 parts of compilation on a few object files (yea, it’s weird, I have no clue what was going on internally here). I found a few quick and dirty solutions to this problem by playing around with optimization settings, but eventually hit a brick wall, where no amount of fidgeting with optimization parameters resulted in compilation/linking going forward. Installing SP1 solved the issue and may have solved the earlier issues as well without me having to play with optimization settings.
So, onwards we go,
- I found that after opening the WebKit solution, none of the projects were loaded. This is because the project files are looking for *.vsprops files in WebKit\WebKitLibraries\tools\vsprops, but the vsprops files are actually in WebKit\WebKitLibraries\win\tools\vsprops. The simplest solution is just copy over what’s in the /win directory into the parent directory (WebKit\WebKitLibraries). Looking at WebKit\WebKitLibraries now, I copied over the win/tools folder and the files in /win. Alternatively, you can edit the project files (they’re XML files, you can open them up in a text editor).
- Set the 2 environment variables necessary for compiling within VC++,
- WEBKITLIBRARIESDIR = cygwin\home\<user>\WebKit\WebKitLibraries
- WEBKITOUTPUTDIR = cygwin\home\<user>\WebKit\WebKitBuild
- Get the Platform SDK, specifically the Windows Server 2003 Ed. of the Platform SDK. I did not have luck getting it to work with an older or newer version of the SDK. I didn’t install the R2 update; I’m not sure what effect it would have.
- Update VC++ directories:
- Executables >> add cygwin/bin, windows/system32, Platform SDK/bin
- Includes >> Platform SDK/include
- Library Files >> Platform SDK/lib
- Update VC++ directories for the WebKit Support Library:
- Includes >> WebKit\WebKitSupportLibrary\WebKitSupportLibrary\win\include
- Library Files >> WebKit\WebKitSupportLibrary\WebKitSupportLibrary\win\lib
- Update VC++ directories for JavaScriptCore/icu:
- Includes >> WebKit\JavaScriptCore\icu
- Update VC++ directories for WebCoreSQLite3:
- Includes >> WebKit\WebKitLibraries\WebCoreSQLite3
- Update VC++ directories for JavaScriptCore:
- Includes >> WebKit\JavaScriptCore
- I had issues with the ARRAYSIZE macro not being defined, so in WebCore/config.h, add the following:
#ifndef ARRAYSIZE
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
#endif
right before the line,
#endif /* PLATFORM(WIN_OS) */
- Get rid of cygwin’s link.exe in cygwin/bin (rename it or delete it). This causes a conflict with the real linker (VC++’s link.exe). It was likely caused by the order in which VC++ executable directories were set, so if you need it, you might be able to keep it.
- For the QtMovieWin project, edit all source files (there’s only 2) so that windows.h is included first (this is due to macro above, which will now cause a macro redefinition by the preprocessor).
- For QtMovieWin, also rearrange the order of include, so that #include <wtf/Vector.h> is included before config.h and windows.h to prevent some min/max macro nonsense.
- For QtMovieWin, take off prompt error reporting for linking (ERRORREPORT:PROMPT) project (see Linker >> Advanced page in project setting).
- Make a new config file by copying WebCore/config.h and making WebCore/config_qt.h. Remove the ARRAYSIZE macro defintions from config_qt.h. Update all files in QtMovieWin project so that config_qt.h is included instead of config.h.
- Install the QuickTime SDK.
- Update VC++ directories:
- Includes >> QuickTime 7.3 SDK\CIncludes
- Library Files >> QuickTime 7.3 SDK\Libraries
- For QtMovieWin, make sure you linker inputs are set correctly for QuickTime libraries and VC++ can find them.
- For QtMovieWin, add “CoreFoundation.lib” to linker inputs.
- (This may have been an issue caused by not having SP1, you might not have to do this, try compiling first) Turn off whole program optimization for all projects.
- (This may have been an issue caused by not having SP1, you might not have to do this, try compiling first) Turn off treat warnings as errors for JavaScriptCore, WebKit, WebKitGUID, WebCore, and WTF projects.
That should do it.
Some general advice, work from within VC++ and compile as you make changes; make it a touch-and-go operation. In this way you see errors as they occur and can more easily spot and fix issues. Don’t simply follow what I’ve written above as tutorial thinking it’s a sure-fire solution for compilation, things may very likely change with different iterations of the code.