1 install qt,libpng, cmake, and ninja.
https://github.com/annulen/webkit/wiki/Building-QtWebKit-on-OS-X
2 add the path to qmake to $PATH
export PATH=$PATH:/Users/wyl/Qt5.6.1/5.6/clang_64/bin
echo $PATH
http://www.cyberciti.biz/faq/appleosx-bash-unix-change-set-path-environment-variable/
3 unzip qtwebkit-opensource-src-5.6.1.tar.xz and rename it qtwebkit
http://download.qt.io/community_releases/5.6/5.6.1/
4 move qtwebkit into my Qt source tree
5 cd to qtwebkit
6 qmake
7 make
可能出错问题:
(1)
x86_64-apple-darwin13.4.0-clang++: No such file or directory
查看qmake生成出来的Makefile文件中的qmake路径,有可能设置错误。环境变量导致的。查看.bash_profile 文件。
(2)
flex --noline --nounistd --outfile=generated/Tokenizer_lex.cpp src/compiler/preprocessor/Tokenizer.l
make[2]: *** [generated/Tokenizer_lex.cpp] Error 1
make[1]: *** [sub-DerivedSources-pri-make_first-ordered] Error 2
make: *** [sub-Source-ThirdParty-ANGLE-ANGLE-pro-make_first-ordered] Error 2
brew install flex
(3)
bison --no-lines --skeleton=yacc.c --defines=generated/glslang_tab.h --output=generated/glslang_tab.cpp src/compiler/glslang.y
make[2]: *** [generated/glslang_tab.h] Abort trap: 6
make[1]: *** [sub-DerivedSources-pri-make_first-ordered] Error 2
make: *** [sub-Source-ThirdParty-ANGLE-ANGLE-pro-make_first-ordered] Error 2
brew install bison
(4)
"glslang_scan(unsigned long, char const* const*, int const*, TParseContext*)", referenced from:
"glslang_finalize(TParseContext*)", referenced from:
"glslang_initialize(TParseContext*)", referenced from:
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [../lib/QtWebKit.framework/QtWebKit] Error 1
make[2]: *** [release-all] Error 2
make[1]: *** [sub-api-pri-make_first-ordered] Error 2
make: *** [sub-Source-QtWebKit-pro-make_first-ordered] Error 2
原因:这个libANGLE.a库中没有编译到这几个函数,这几个函数应该都在glslang_lex.cpp 和 Tokenizer_lex.cpp文件中
flex --noline --nounistd --outfile=generated/glslang_lex.cpp src/compiler/glslang.l
flex --noline --nounistd --outfile=generated/Tokenizer_lex.cpp src/compiler/preprocessor/Tokenizer.l
这两句命令没起作用,编译出来的glslang_lex.cpp 和 Tokenizer_lex.cpp是空的。 更换了机器直接使用命令flex 将这两个文件编译好。
Symbols: bootstrap_look_up2, bootstrap_register2
From framework: /usr/lib/libSystem.B.dylib
Symbols: ubrk_getRuleStatus, ucnv_reset, _ucnv_getCanonicalName
From framework: /usr/lib/libicucore.A.dylib
In binary: Contents/MacOS/qt_lib/lib/QtWebKit
(1)
Symbols: bootstrap_look_up2, bootstrap_register2
From framework: /usr/lib/libSystem.B.dylib
In binary: Contents/MacOS/qt_lib/lib/QtWebKit
WebKit2 :这两个函数都在WebKit2中使用。
解决方法:
~/Qt5.6.1/5.6/Src/qtwebkit/Tools/qmake/mkspecs/features/configure.prf
WEBKIT_CONFIG += \
build_webkit1 \
build_webkit2 \
build_tests \
$$WEBKIT_TOOLS_CONFIG
改成:
WEBKIT_CONFIG += \
build_webkit1 \
build_tests \
$$WEBKIT_TOOLS_CONFIG
(2)
Symbols: ubrk_getRuleStatus, ucnv_reset, _ucnv_getCanonicalName
From framework: /usr/lib/libicucore.A.dylib
In binary: Contents/MacOS/qt_lib/lib/QtWebKit
涉及到使用这些接口的文件 JavaScriptCore WebCore WebKit WTF
解决方法:
~/Qt5.6.1/5.6/Src/qtwebkit/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
bool isWordTextBreak(TextBreakIterator* iterator)
{
return true;
// int ruleStatus = ubrk_getRuleStatus(reinterpret_cast(iterator));
// return ruleStatus != UBRK_WORD_NONE;
}
~/Qt5.6.1/5.6/Src/qtwebkit/Source/WebCore/platform/text/TextCodecICU.cpp
//ucnv_reset(m_converterICU);
// const char* canonicalConverterName = ucnv_getCanonicalName("ISO-8859-8-I", "IANA", &error);
const char* canonicalConverterName = "ibm-5012_P100-1999";
参考网页:
1 Building QtWebKit on OS X
https://github.com/annulen/webkit/wiki/Building-QtWebKit-on-OS-X
2 How to build qtwebkit on mac?
https://forum.qt.io/topic/71645/how-to-build-qtwebkit-on-mac
3 macOS 10.13.6 下编译 Qt 5.7.1 动态链接版 + QtWebKit 5.7.1
https://www.jianshu.com/p/623781fb4ffe