[转载]WebKit 内核编译

[转载]WebKit 内核编译 – elfylin的专栏 – 博客频道 – CSDN.NET.

WebKit内核编译实在是一项折磨人的事情,虽然webkit.org官方有一个文档,但是有时候机器本身配置环境还是和教程有差别。

经过三天三夜平均每天2点钟的奋斗,今天终于搞定了。

 

其实,官方的描述已经非常到位,只要保证每一步都执行了,差别应该不大,需要多加处理的就是本机实际环境导致的具体问题。

 

首先按照官方文档进行操作

http://www.webkit.org/building/tools.html

一、安装Visual 2005

  1. 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:

    1. KB918559
    2. KB935225
    3. KB943969
    4. KB947315

    Use the default options for these installations.

(我在装下面四个补丁的时候提示找不到升级的程序,我装的是2005 中文版,估计补丁有问题,后来没有理会了)

二、安装cygwin

  1. 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.exe from 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_proxy environment 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 implementingfork(the POSIX function frequently used to start child processes, needed by many of the WebKit build tools).In order to enablecygwin1.dll to 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.dll andcygwin1.dll to base addresses that cause them to not overlap in memory.

    In order to rebase all cygwin dlls a rebaseall script is provided in the cygwin installation’sbin directory(usuallyC:\cygwin\bin).This script must be run fromash.exe (found in the same directory) while no other cygwin application is running.
    ash.exe has very limited command line editing features so cutting and pasting to the commandline is recommended.
    The PATH environment variable may not contain the /bin directory by defaultthus the script should be launched as/bin/rebaseall.
    If rebaseall is 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 torebaseall via the-T fileName commandline argument.The dlls underLayoutTests/http/conf are a relevant use case.

    Remove the following lines from /home/[username]/.bashrc (if present):

    unset TMP
    unset TEMP

    Those 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.

(上面的每一步都要执行,包括用他cygwin配置,执行ash.exe /binrebaseall)

 

三 安装 QuickTime SDK和 DirectX SDK

  1. 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.

  2. Install DirectX SDK

    Download the February 2010 DirectX SDK (newer versions do not support Visual Studio 2005). This is needed for accelerated compositing.

(都要装)

 

四 其他

  1. 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.

  2. 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冲突。

这个问题,我遇到没搞定,后来重装的系统,这个问题就没出现了。

赞(0) 打赏
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏