WebKit內核編譯實在是一項折磨人的事情,雖然webkit.org官方有一個文檔,但是有時候機器本身配置環境還是和教程有差別。
經過三天三夜平均每天2點鍾的奮斗,今天終於搞定了。
其實,官方的描述已經非常到位,只要保證每一步都執行了,差別應該不大,需要多加處理的就是本機實際環境導致的具體問題。
首先按照官方文檔進行操作
http://www.webkit.org/building/tools.html
一、安裝Visual 2005
If you own Visual Studio 2005 (newer versions of Visual Studio are currently unsupported):
Install Microsoft Visual Studio 2005 Team Suite Service Pack 1.
If you are building from Vista, install Service Pack 1 Update for Windows Vista.
Install Visual Studio 2005 Service Pack 1 ATL Security Update.
Install the following hotfixes to improve Visual Studio's performance and responsiveness:
Use the default options for these installations.
二、安裝cygwin
Install Cygwin
Cygwin is a collection of utilities for Windows that includes not only a Subversionclient, but also additional tools that are required to build the WebKit source. Wehave made a downloader available that automatically collects all of the requiredpackages.
Download cygwin-downloader.zip.
Extract the content of the archive to some folder and start
cygwin-downloader.exefrom that folder.This will download all the Cygwin packages you need.When all the packages have finished downloading, the Cygwin installer will launch. ChooseInstall from Local Directory, then clickNext until theinstall is complete. If you are running Vista, the installer won't be able to launch automatically, so you will have to manually launch Cygwin's Setup.exe.
Note: If you are behind a proxy you need to set the
http_proxyenvironment variable to the URL of the proxy. This wouldlikely match this pattern:http[s]://[username[:password]@]somehost.com[:port]. Where the square brackets ([]) are not part of the url but enclose url elements that are optional indicating that those elements might be missing in your case together with their enclosed delimiter such as @ and :.Note: Vista may warn you that Cygwin did not install correctly. Ignore this warning and tell Vista that the install was successful.
Warning: If you are running Vista or Windows 7, Cygwin may have trouble with implementing
fork(the POSIX function frequently used to start child processes, needed by many of the WebKit build tools).In order to enablecygwin1.dllto implement fork successfully it is better if no DLL loaded in the parent process is relocated at runtime.One way to achive this is to rebase all cygwin dlls exceptcyglsa64.dllandcygwin1.dllto base addresses that cause them to not overlap in memory.In order to rebase all cygwin dlls a
rebaseallscript is provided in the cygwin installation'sbindirectory(usuallyC:\cygwin\bin).This script must be run fromash.exe(found in the same directory) while no other cygwin application is running.ash.exehas very limited command line editing features so cutting and pasting to the commandline is recommended.
ThePATHenvironment variable may not contain the/bindirectory by defaultthus the script should be launched as/bin/rebaseall.
Ifrebaseallis complaining about failure to write to a Windows Temp directory (i.e./cygdrive/c/Users/you/AppData/Local/Temp),fix the permissions on that folder (i.e./bin/chown you /cygdrive/c/Users/you/AppData/Local/Temp) orchange the TMP environment variable to point to a directory with the appropriate permission flags (i.e.:export TMP=/tmp).Note: The rebase process may need to be repeated to include any new libraries added later to cygwin by listing these libraries by full cygwin path in a file and passing the file to
rebaseallvia the-T fileNamecommandline argument.The dlls underLayoutTests/http/confare a relevant use case.Remove the following lines from
/home/[username]/.bashrc(if present):unset TMPunset TEMPThose lines would prevent picking up the Windows TMP and TEMP environment variables.If you are behind a proxy you need to do the following to allow cygwin svn to get through the proxy (similar steps are available for your Windows svn):
- In bash (Cygwin) run:
svn help. This will create in your cygwin home directory the file .subversion/servers. - Edit the file mentioned above and follow the instructions in the file to set up your proxy settings.
- In bash (Cygwin) run:
三 安裝 QuickTime SDK和 DirectX SDK
Install QuickTime SDK
Download QuickTime SDK for Windows from http://developer.apple.com/quicktime/download/ and install it to the default location (\Program Files\QuickTime SDK). This is needed for media support.
Install DirectX SDK
Download the February 2010 DirectX SDK (newer versions do not support Visual Studio 2005). This is needed for accelerated compositing.
四 其他
Optional: Install the 32-bit version of Debugging Tools for Windows
Debugging Tools for Windows includes many useful debugging tools such as WinDbg and NTSD. Some of WebKit’s tests and scripts use these tools. Follow theinstructions for installing the 32-bit version of Debugging Tools for Windows.
Optional: Hotfix for 64-bit Windows to disable the user-mode callback filter for exceptions
Without the 976038 hotfix, exceptions may be thrown in callback routines that do not cause a crash but leave the application in an inconsistent state that might cause a crash later. You will need to click on "View and request hotfix downloads" and fill out the form. A link to download the hotfix and a password will be emailed to you.
(編譯通過的時候這些我沒裝),最后還是通過了。
五 總結一下
需要我們自己做的事情
更改VC為DEBUG、設置“警告作為錯誤”為false、
編譯錯誤和解決
首先,這一篇文檔算是比較全的。
http://hi.baidu.com/ksoftware/blog/item/75dace1f94750179f724e457.html
轉載一下
1) ERROR # PRJ0018 : 未找到下列環境變量: >$(WebKitOutputDir)
SOLUTION # 添加環境變量WebKitOutputDir
2) ERROR # fatal error C1083: 無法打開包括文件:“unicode/uchar.h”: No such file or directory
# fatal error C1083: 無法打開包括文件:“pthread.h”: No such file or directory
# 'grep' 不是內部或外部命令,也不是可運行的程序或批處理文件
# fatal error C1083: 無法打開包括文件:“WebKit2/WebKit2.h”: No such file or directory
# error LNK2019: 無法解析的外部符號 _u_charType_3_2,該符號在函數 "bool __cdecl WTF::Unicode::isSeparatorSpace(int)" (?isSeparatorSpace@Unicode@WTF@@YA_NH@Z) 中被引用
SOLUTION # run update-webkit and build-webkit scripts again
3) ERROR # error PRJ0002 : 錯誤的結果 1 (從“C:\WINDOWS\system32\cmd.exe”返回)
SOLUTION # 關聯錯誤 無需修正
4) ERROR # error C2220: 警告被視為錯誤 - 沒有生成“object”文件
# error C2001: 常量中有換行符
# fatal error C1057: 宏展開中遇到意外的文件結束
SOLUTION # 發現DefaultLocalizationStrategy.cpp中的雙引號格式為全角格式,改成半角並加轉義。
#if USE(CF)
RetainPtr<CFStringRef> selectedCFString(AdoptCF, truncatedStringForLookupMenuItem(selectedString).createCFString());
return formatLocalizedString(WEB_UI_STRING("Look Up \"%@\"", "Look Up context menu item with selected word"), selectedCFString.get());
#else
return WEB_UI_STRING("Look Up \"<selection>\"", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));
#endif
5) ERROR # error MIDL2152 : [version] format is incorrect
# error MIDL2214 : semantic check incomplete due to previous errors
SOLUTION # 查看WebKid.idl 定位到150行 version(__TYPELIB_VERSION__) 發現一個version的函數
#define __TYPELIB_VERSION__ __BUILD_NUMBER_MAJOR__##.##__BUILD_NUMBER_MINOR__
試了下修改為
#define __TYPELIB_VERSION__ 0.1
重新生成,成功。
6) ERROR # error C2220: 警告被視為錯誤 - 沒有生成“object”文件
SOLUTION # 在vs2005中重新保存即可
(我下載的是WebKit-r94831.tar.bz2 ,遇到了ERROR # error C2220: 警告被視為錯誤 - 沒有生成“object”文件,要安裝上面修改,於此同時要關閉警告被視為錯誤的VC編譯選項)
其次,連接錯誤
參見這篇博客http://blog.csdn.net/dummas/article/details/3871134
1>Linking...
11>LINK : warning LNK4044: unrecognized option '/dynamicbase'; ignored
11> Creating library D:/liangjh/WebKit-r40102/WebKitBuild/lib/WebKit.lib and o
bject D:/liangjh/WebKit-r40102/WebKitBuild/lib/WebKit.exp
11>WebCore_debug.lib(CSSGradientValue.obj) : error LNK2001: unresolved external
symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(voi
d)const " (__imp_?_Raise@exception@std@@QBEXXZ)
11>WebCore_debug.lib(RenderLayer.obj) : error LNK2019: unresolved external symbo
l "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)con
st " (__imp_?_Raise@exception@std@@QBEXXZ) referenced in function "struct std::p
air<class WebCore::RenderLayer * *,int> __cdecl std::get_temporary_buffer<class
WebCore::RenderLayer *>(int)" (??$get_temporary_buffer@PAVRenderLayer@WebCore@@@
std@@YA?AU?$pair@PAPAVRenderLayer@WebCore@@H@0@H@Z)
11>WebCore_debug.lib(Gradient.obj) : error LNK2001: unresolved external symbol "
__declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const
" (__imp_?_Raise@exception@std@@QBEXXZ)
11>WebCore_debug.lib(CSSFontSelector.obj) : error LNK2001: unresolved external s
ymbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void
)const " (__imp_?_Raise@exception@std@@QBEXXZ)
11>WebCore_debug.lib(CompositeAnimation.obj) : error LNK2001: unresolved externa
l symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(v
oid)const " (__imp_?_Raise@exception@std@@QBEXXZ)
11>WebCore_debug.lib(CSSGradientValue.obj) : error LNK2001: unresolved external
symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char
const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z)
11>WebCore_debug.lib(RenderLayer.obj) : error LNK2019: unresolved external symbo
l "__declspec(dllimport) public: __thiscall std::exception::exception(char const
*,int)" (__imp_??0exception@std@@QAE@PBDH@Z) referenced in function "public: __
thiscall std::bad_alloc::bad_alloc(char const *)" (??0bad_alloc@std@@QAE@PBD@Z)
11>WebCore_debug.lib(Gradient.obj) : error LNK2001: unresolved external symbol "
__declspec(dllimport) public: __thiscall std::exception::exception(char const *,
int)" (__imp_??0exception@std@@QAE@PBDH@Z)
11>WebCore_debug.lib(CSSFontSelector.obj) : error LNK2001: unresolved external s
ymbol "__declspec(dllimport) public: __thiscall std::exception::exception(char c
onst *,int)" (__imp_??0exception@std@@QAE@PBDH@Z)
11>WebCore_debug.lib(CompositeAnimation.obj) : error LNK2001: unresolved externa
l symbol "__declspec(dllimport) public: __thiscall std::exception::exception(cha
r const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z)
11>WebCore_debug.lib(CSSGradientValue.obj) : error LNK2001: unresolved external
symbol "__declspec(dllimport) void __cdecl std::_Throw(class std::exception cons
t &)" (__imp_?_Throw@std@@YAXABVexception@1@@Z)
11>WebCore_debug.lib(RenderLayer.obj) : error LNK2019: unresolved external symbo
l "__declspec(dllimport) void __cdecl std::_Throw(class std::exception const &)"
(__imp_?_Throw@std@@YAXABVexception@1@@Z) referenced in function "protected: vi
rtual void __thiscall std::bad_alloc::_Doraise(void)const " (?_Doraise@bad_alloc
@std@@MBEXXZ)
11>WebCore_debug.lib(Gradient.obj) : error LNK2001: unresolved external symbol "
__declspec(dllimport) void __cdecl std::_Throw(class std::exception const &)" (_
_imp_?_Throw@std@@YAXABVexception@1@@Z)
11>WebCore_debug.lib(CSSFontSelector.obj) : error LNK2001: unresolved external s
ymbol "__declspec(dllimport) void __cdecl std::_Throw(class std::exception const
&)" (__imp_?_Throw@std@@YAXABVexception@1@@Z)
11>WebCore_debug.lib(CompositeAnimation.obj) : error LNK2001: unresolved externa
l symbol "__declspec(dllimport) void __cdecl std::_Throw(class std::exception co
nst &)" (__imp_?_Throw@std@@YAXABVexception@1@@Z)
11>D:/liangjh/WebKit-r40102/WebKitBuild/bin/WebKit.dll : fatal error LNK1120: 3
unresolved externals
11>Project : warning PRJ0018 : The following environment variables were not foun
d:
11>$(PRODUCTION)
11>Build log was saved at "file://D:/liangjh/WebKit-r40102/WebKitBuild/obj/WebKi
t/Debug/BuildLog.htm"
11>WebKit - 16 error(s), 14 warning(s)
這篇博客說,是google STL有關,要修改 WebKit/WebCore/config.h里面,在<wtf/platform.h>上面加上
#define _HAS_EXCEPTIONS 0
#define _STATIC_CPPLIB
但是,我這么做事失敗了的。搞了很久發現自己有一個東西忘安裝了Install Microsoft Visual C++ Express 2005 Service Pack 1,官方下載的是
VS80sp1-KB926601-X86-ENU.exe,其實這個我這里裝不起,后來裝了VS80sp1-KB926604-X86-CHS.exe,才解決了這個問題。
最后,其他連接錯誤
正在創建庫 D:\WEBKIT\webkitH\WebKitBuild\lib\JavaScriptCore.lib 和對象 D:\WEBKIT\webkitH\WebKitBuild\lib\JavaScriptCore.exp
3>FunctionPrototype.obj : error LNK2019: 無法解析的外部符號 _u_charType_46,該符號在函數 "bool __cdecl WTF::Unicode::isSeparatorSpace(int)" (?isSeparatorSpace@Unicode@WTF@@YA_NH@Z) 中被引用
3>JSGlobalObjectFunctions.obj : error LNK2001: 無法解析的外部符號 _u_charType_46
3>Lexer.obj : error LNK2001: 無法解析的外部符號 _u_charType_46
3>StringPrototype.obj : error LNK2019: 無法解析的外部符號 _u_strToLower_46,該符號在函數 "int __cdecl WTF::Unicode::toLower(wchar_t *,int,wchar_t const *,int,bool *)" (?toLower@Unicode@WTF@@YAHPA_WHPB_WHPA_N@Z) 中被引用
3>WTF.lib(StringImpl.obj) : error LNK2001: 無法解析的外部符號 _u_strToLower_46
3>StringPrototype.obj : error LNK2019: 無法解析的外部符號 _u_strToUpper_46,該符號在函數 "int __cdecl WTF::Unicode::toUpper(wchar_t *,int,wchar_t const *,int,bool *)" (?toUpper@Unicode@WTF@@YAHPA_WHPB_WHPA_N@Z) 中被引用
3>WTF.lib(StringImpl.obj) : error LNK2001: 無法解析的外部符號 _u_strToUpper_46
3>RegexCompiler.obj : error LNK2019: 無法解析的外部符號 _u_tolower_46,該符號在函數 "int __cdecl WTF::Unicode::toLower(int)" (?toLower@Unicode@WTF@@YAHH@Z) 中被引用
3>RegexInterpreter.obj : error LNK2001: 無法解析的外部符號 _u_tolower_46
3>RegexJIT.obj : error LNK2001: 無法解析的外部符號 _u_tolower_46
3>RegexCompiler.obj : error LNK2019: 無法解析的外部符號 _u_toupper_46,該符號在函數 "int __cdecl WTF::Unicode::toUpper(int)" (?toUpper@Unicode@WTF@@YAHH@Z) 中被引用
3>RegexInterpreter.obj : error LNK2001: 無法解析的外部符號 _u_toupper_46
3>RegexJIT.obj : error LNK2001: 無法解析的外部符號 _u_toupper_46
3>WTF.lib(StringImpl.obj) : error LNK2019: 無法解析的外部符號 _u_strFoldCase_46,該符號在函數 "int __cdecl WTF::Unicode::foldCase(wchar_t *,int,wchar_t const *,int,bool *)" (?foldCase@Unicode@WTF@@YAHPA_WHPB_WHPA_N@Z) 中被引用
3>WTF.lib(StringImpl.obj) : error LNK2019: 無法解析的外部符號 _u_charDirection_46,該符號在函數 "enum WTF::Unicode::Direction __cdecl WTF::Unicode::direction(int)" (?direction@Unicode@WTF@@YA?AW4Direction@12@H@Z) 中被引用
3>WTF.lib(WTFString.obj) : error LNK2001: 無法解析的外部符號 _u_charDirection_46
3>WTF.lib(StringImpl.obj) : error LNK2019: 無法解析的外部符號 _u_foldCase_46,該符號在函數 "int __cdecl WTF::Unicode::foldCase(int)" (?foldCase@Unicode@WTF@@YAHH@Z) 中被引用
3>WTF.lib(StringImpl.obj) : error LNK2019: 無法解析的外部符號 _u_memcasecmp_46,該符號在函數 "int __cdecl WTF::Unicode::umemcasecmp(wchar_t const *,wchar_t const *,int)" (?umemcasecmp@Unicode@WTF@@YAHPB_W0H@Z) 中被引用
3>WTF.lib(CollatorICU.obj) : error LNK2019: 無法解析的外部符號 _ucol_strcoll_46,該符號在函數 "public: enum WTF::Collator::Result __thiscall WTF::Collator::collate(wchar_t const *,unsigned int,wchar_t const *,unsigned int)const " (?collate@Collator@WTF@@QBE?AW4Result@12@PB_WI0I@Z) 中被引用
3>WTF.lib(CollatorICU.obj) : error LNK2019: 無法解析的外部符號 _ucol_setAttribute_46,該符號在函數 "private: void __thiscall WTF::Collator::createCollator(void)const " (?createCollator@Collator@WTF@@ABEXXZ) 中被引用
3>WTF.lib(CollatorICU.obj) : error LNK2019: 無法解析的外部符號 _ucol_open_46,該符號在函數 "private: void __thiscall WTF::Collator::createCollator(void)const " (?createCollator@Collator@WTF@@ABEXXZ) 中被引用
3>WTF.lib(CollatorICU.obj) : error LNK2019: 無法解析的外部符號 _ucol_getAttribute_46,該符號在函數 "private: void __thiscall WTF::Collator::createCollator(void)const " (?createCollator@Collator@WTF@@ABEXXZ) 中被引用
3>WTF.lib(CollatorICU.obj) : error LNK2019: 無法解析的外部符號 _ucol_getLocaleByType_46,該符號在函數 "private: void __thiscall WTF::Collator::createCollator(void)const " (?createCollator@Collator@WTF@@ABEXXZ) 中被引用
3>WTF.lib(CollatorICU.obj) : error LNK2019: 無法解析的外部符號 _ucol_close_46,該符號在函數 "private: void __thiscall WTF::Collator::releaseCollator(void)" (?releaseCollator@Collator@WTF@@AAEXXZ) 中被引用
3>D:\WEBKIT\webkitH\WebKitBuild\bin\JavaScriptCore.dll : fatal error LNK1120: 15 個無法解析的外部命令
google搜索是什么icu3.2 icu4.0的東西,后面涉及到什么VS2005 2008沖突。
這個問題,我遇到沒搞定,后來重裝的系統,這個問題就沒出現了。
這個就是不斷查找,不斷嘗試,本來都打算放棄了的,但是不甘心,最后終於成功了,也祝大家編譯順利。
