2023年12月24日发(作者:)
WebKit内核编译实在是一项折磨人的事情,虽然官方有一个文档,但是有时候机器本身配置环境还是和教程有差别。其实,官方的描述已经非常到位,只要保证每一步都执行了,差别应该不大,需要多加处理的就是本机实际环境导致的具体问题。
首先按照官方文档进行操作
/building/
一、安装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:
KB918559
KB935225
KB943969
KB947315
Use the default options for these installations.
注意点: 如果Visual Studio 2005装的是中文版,补丁程序必须要是中文版
二、安装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 .
Extract the content of the archive to some folder and start
from that 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 .
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]@][: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 to implement
fork successfully it is better if no DLL loaded in the parent process is relocated
at way to achive this is to rebase all cygwin dlls
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:cygwinbin).This script must be run
(found in the same directory) while no other cygwin application is
running.
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 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.
本人用的是XP,只需默认安装,不需配置。
三、 安装 QuickTime SDK和 DirectX SDK
Install QuickTime SDK
Download QuickTime SDK for Windows from
/quicktime/download/ and install it to the default
location (Program FilesQuickTime 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.
注:可以不安装
五、 编译
1.打开Cygwin,进入WebKit/WebKitTools/Scripts文件夹运行一下
./update-webkit是个更新脚本,不运行这个编译的时候是肯定要出错的。
Update-webkit可能出现的错误
原因:你的cygwin安装不完全,最好重新运行,重新安装cygwin.
2、先设置两个环境变量WEBKITOUTPUTDIR和WEBKITLIBRARIESDIR。第一个环境变量可以随便设,如果要保持和其他Build方式的一致性,那么就设置成为%WEBKIT_DIR%WebKitBuild,这里%WEBKIT_DIR%当然就是指您的Webkit文件夹的绝对路径。第二个环境变量必须设置为%WEBKIT_DIR%WebKitLibrarieswin文件夹。
3. 如果您机器上安装过Qt,那么检查一下环境变量里面是不是有QTDIR,如有,删了先;如果有这个环境变量,Webkit的build脚本会认为要编译Qt的port。
4. 用vs2005打开,选择正确的Configuration,也就是Debug和Release,为啥要说这个呢,因为Webkit在Windows下不止一个port,也就不止一个Debug和一个Release,这里我们要选的就是单纯的Debug和Release,其他的Build配置就忽略吧。
5. 虽然理论上说现在已经可以编译了,但是由于该死的quicktime sdk,您还得再忙活一下:选择DumpRenderTree, QTMovieWin, WebCore, WebKit, WinLauncher等项目(反
正把c++项目的该属性都设置一遍就对了)的项目属性,左侧选择“C/C++”,将右侧的”Treat Warnings As Errors”设置为”No”。
6. 到这里,才可以说万事俱备了,按下F7(Build Solution),然后双手合十,祈祷吧,如果一切顺利,一至数个小时后(依据您机器的性能),Webkit就成功的编辑结束了。
六、编译错误和解决
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:”返回)
SOLUTION # 关联错误 无需修正
4) ERROR # error C2220: 警告被视为错误 - 没有生成“object”文件
# error C2001: 常量中有换行符
# fatal error C1057: 宏展开中遇到意外的文件结束
SOLUTION # 发现中的双引号格式为全角格式,改成半角并加转义。
#if USE(CF)
RetainPtr
selectedCFString(AdoptCF,truncatedStringForLookupMenuItem(selectedString).creat
eCFString());
return formatLocalizedString(WEB_UI_STRING("Look Up "%@"", "Look Up context
menu item with selected word"), ())
#else
return WEB_UI_STRING("Look Up "
with selected word").replace("
truncatedStringForLookupMenuItem(selectedString));
#endif
5) ERROR # error MIDL2152 : [version] format is incorrect
# error MIDL2214 : semantic check incomplete due to previous errors
SOLUTION # 查看 定位到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中重新保存即可
七、链接错误和解决
11>LINK : warning LNK4044: unrecognized option '/dynamicbase'; ignored
11> Creating library D:/liangjh/WebKit-r40102/WebKitBuild/lib/ and o
bject D:/liangjh/WebKit-r40102/WebKitBuild/lib/
11>WebCore_() : error LNK2001: unresolved external
symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(voi
d)const " (__imp_?_Raise@exception@std@@QBEXXZ)
11>WebCore_() : 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 WebCore::RenderLayer *>(int)" (??$get_temporary_buffer@PAVRenderLayer@WebCore@@@ std@@YA?AU?$pair@PAPAVRenderLayer@WebCore@@H@0@H@Z) 11>WebCore_() : error LNK2001: unresolved external symbol " __declspec(dllimport) public: void __thiscall std::exception::_Raise(void)const " (__imp_?_Raise@exception@std@@QBEXXZ) 11>WebCore_() : error LNK2001: unresolved external s ymbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(void )const " (__imp_?_Raise@exception@std@@QBEXXZ) 11>WebCore_() : error LNK2001: unresolved externa l symbol "__declspec(dllimport) public: void __thiscall std::exception::_Raise(v oid)const " (__imp_?_Raise@exception@std@@QBEXXZ) 11>WebCore_() : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::exception::exception(char const *,int)" (__imp_??0exception@std@@QAE@PBDH@Z) 11>WebCore_() : 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_() : error LNK2001: unresolved external symbol " __declspec(dllimport) public: __thiscall std::exception::exception(char const *, int)" (__imp_??0exception@std@@QAE@PBDH@Z) 11>WebCore_() : 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_() : 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_() : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl std::_Throw(class std::exception cons t &)" (__imp_?_Throw@std@@YAXABVexception@1@@Z) 11>WebCore_() : 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_() : error LNK2001: unresolved external symbol " __declspec(dllimport) void __cdecl std::_Throw(class std::exception const &)" (_ _imp_?_Throw@std@@YAXABVexception@1@@Z) 11>WebCore_() : error LNK2001: unresolved external s ymbol "__declspec(dllimport) void __cdecl std::_Throw(class std::exception const &)" (__imp_?_Throw@std@@YAXABVexception@1@@Z) 11>WebCore_() : 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/ : 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/" 11>WebKit - 16 error(s), 14 warning(s) 解决方法:安装 Microsoft Visual C++ Express 2005 Service Pack 1


发布评论