1.下载QT源码:Index of /archive/qt/4.8/4.8.6
2.把源码解压
3.打开文件“qmake\generators\win32\winmakefile.cpp”,更改内容如下:
//ts << "VS_VERSION_INFO VERSIONINFO" << endl;
//ts << "\tFILEVERSION " << QString(versionString).replace(".", ",") << endl;
//ts << "\tPRODUCTVERSION " << QString(versionString).replace(".", ",") << endl;
//ts << "\tFILEFLAGSMASK 0x3fL" << endl;
//ts << "#ifdef _DEBUG" << endl;
//ts << "\tFILEFLAGS VS_FF_DEBUG" << endl;
//ts << "#else" << endl;
//ts << "\tFILEFLAGS 0x0L" << endl;
//ts << "#endif" << endl;
//ts << "\tFILEOS VOS__WINDOWS32" << endl;
//if (project->isActiveConfig("shared"))
// ts << "\tFILETYPE VFT_DLL" << endl;
//else
// ts << "\tFILETYPE VFT_APP" << endl;
//ts << "\tFILESUBTYPE 0x0L" << endl;
//ts << "\tBEGIN" << endl;
//ts << "\t\tBLOCK \"StringFileInfo\"" << endl;
//ts << "\t\tBEGIN" << endl;
//ts << "\t\t\tBLOCK \""
// << QString("%1%2").arg(rcLang, 4, 16, QLatin1Char('0')).arg(rcCodePage, 4, 16, QLatin1Char('0'))
// << "\"" << endl;
//ts << "\t\t\tBEGIN" << endl;
//ts << "\t\t\t\tVALUE \"CompanyName\", \"" << companyName << "\\0\"" << endl;
//ts << "\t\t\t\tVALUE \"FileDescription\", \"" << description << "\\0\"" << endl;
//ts << "\t\t\t\tVALUE \"FileVersion\", \"" << versionString << "\\0\"" << endl;
//ts << "\t\t\t\tVALUE \"LegalCopyright\", \"" << copyright << "\\0\"" << endl;
//ts << "\t\t\t\tVALUE \"OriginalFilename\", \"" << originalName << "\\0\"" << endl;
//ts << "\t\t\t\tVALUE \"ProductName\", \"" << productName << "\\0\"" << endl;
//ts << "\t\t\tEND" << endl;
//ts << "\t\tEND" << endl;
//ts << "\t\tBLOCK \"VarFileInfo\"" << endl;
//ts << "\t\tBEGIN" << endl;
//ts << "\t\t\tVALUE \"Translation\", "
// << QString("0x%1").arg(rcLang, 4, 16, QLatin1Char('0'))
// << ", " << QString("%1").arg(rcCodePage, 4) << endl;
//ts << "\t\tEND" << endl;
//ts << "\tEND" << endl;
//ts << "/* End of Version info */" << endl;
//ts << endl;
也就是注释掉上面的内容,否则后面编译会出错“CVTRES : FATAL ERROR CVT1100: 资源重复。类型: VERSION”。
4.打开文件“src\3rdparty\webkit\Source\WebKit\qt\tests\qwebframe\qwebframe.pro”,更改如下内容:
把行:
DEFINES += TESTS_SOURCE_DIR=\"/private/$$replace(TARGET.UID3, 0x,)/\"
更改为:
DEFINES += TESTS_SOURCE_DIR="/private/$$replace(TARGET.UID3, 0x,)/"
也就是删除多余的“\”反斜杠。
5.打开文件“src\3rdparty\webkit\Source\WebKit\qt\tests\tests.pri”,更改内容如下:
把这一行:
!symbian: DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD/\\\"
更改为:
!symbian: DEFINES += TESTS_SOURCE_DIR=\"$$PWD/\"
也就是删除多余的“\\” 。
6.打开文件“src\3rdparty\webkit\Source\WebKit2\UIProcess\API\qt\tests\tests.pri”,更改内容如下:
把这一行代码:
!symbian: DEFINES += TESTS_SOURCE_DIR=\\\"$$PWD\\\"
更改为:
!symbian: DEFINES += TESTS_SOURCE_DIR=\"$$PWD\"
也就是删除多余的“\\” 。
7.在开始菜单中找到vs2012环境命令行,根据自己的需要选择x86或x64
8.在cd /d 到解压目录下“qt-everywhere-opensource-src-4.8.6”
9.执行命令
configure -debug-and-release -opensource -platform win32-msvc2012
再按提示输入“y”,等待生成解决方案
10.使用vs2012打开生成的“projects.sln”解决方案进行编译,编译时会出现两种错误:
错误一:
error C2664: “std::pair<_Ty1,_Ty2>::pair(const std::pair<_Ty1,_Ty2> &)”: 不能将参数 1 从“std::pair<_Ty1,_Ty2>”转换为“const std::pair<_Ty1,_Ty2> &”
解决办法:打开“src\3rdparty\webkit\Source\JavaScriptCore\wtf\HashSet.h” ,修改如下内容
template<typename T, typename U, typename V>
inline pair<typename HashSet<T, U, V>::iterator, bool> HashSet<T, U, V>::add(const ValueType& value)
{
//return m_impl.add(value);
auto p = m_impl.add(value);
return make_pair(typename HashSet<T, U, V>::const_iterator(p.first), p.second);
}
template<typename Value, typename HashFunctions, typename Traits>
template<typename T, typename HashTranslator>
inline pair<typename HashSet<Value, HashFunctions, Traits>::iterator, bool>
HashSet<Value, HashFunctions, Traits>::add(const T& value)
{
//typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
//return m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
typedef HashSetTranslatorAdapter<ValueType, ValueTraits, T, HashTranslator> Adapter;
typedef typename HashSet<Value, HashFunctions, Traits>::iterator iter_type;
auto& temp = m_impl.template addPassingHashCode<T, T, Adapter>(value, value);
return make_pair((iter_type)temp.first, temp.second);
}
错误二:
2>platform\DefaultLocalizationStrategy.cpp(328): error C2001: 常量中有换行符
2>platform\DefaultLocalizationStrategy.cpp(328): fatal error C1057: 宏扩展中遇到意外的文件结束
解决办法:打开“src\3rdparty\webkit\Source\WebCore\platform\DefaultLocalizationStrategy.cpp”,修改如下内容
String DefaultLocalizationStrategy::contextMenuItemTagLookUpInDictionary(const String& selectedString)
{
#if defined(BUILDING_ON_LEOPARD) || defined(BUILDING_ON_SNOW_LEOPARD)
UNUSED_PARAM(selectedString);
return WEB_UI_STRING("Look Up in Dictionary", "Look Up in Dictionary context menu item");
#else
#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());
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));
return WEB_UI_STRING("Look Up \"<selection>\"", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));
#endif
#endif
}
错误三:
4>webcore.lib(PluginViewWin.obj) : error LNK2019: 无法解析的外部符号 _HBeginPaint,该符号在函数 "private: static struct HDC__ * __cdecl WebCore::PluginView::hookedBeginPaint(struct HWND__ *,struct tagPAINTSTRUCT *)" (?hookedBeginPaint@PluginView@WebCore@@CAPEAUHDC__@@PEAUHWND__@@PEAUtagPAINTSTRUCT@@@Z) 中被引用
4>webcore.lib(PluginViewWin.obj) : error LNK2019: 无法解析的外部符号 _HEndPaint,该符号在函数 "private: static int __cdecl WebCore::PluginView::hookedEndPaint(struct HWND__ *,struct tagPAINTSTRUCT const *)" (?hookedEndPaint@PluginView@WebCore@@CAHPEAUHWND__@@PEBUtagPAINTSTRUCT@@@Z) 中被引用
4>..\..\..\..\..\..\lib\\QtWebKitd4.dll : fatal error LNK1120: 2 个无法解析的外部命令
解决方法:
1.选中webcore这个工程,右键-->生成自定义-->勾选“masm(.targets .props)”-->确定
2.把“src\3rdparty\webkit\Source\WebCore\plugins\win\PaintHooks.asm”添加到“webcore”项目中
3.选中刚才添加到“webcore”项目中的“PaintHooks.asm”文件,右键-->属性-->配置属性-->常规-->General-->项类型-->选择“Microsoft Macro Assembler”-->确定
错误四:
CVTRES : FATAL ERROR CVT1100: 资源重复。类型: XXXXX
这个错误有两种方法解决:
方法1.哪个项目出现这个错误,就到那个项目下找到“.rc”文件,点击进去把“XXXXX”类型的资源删除,重新编译项目是会出现“error RC2144: PRIMARY LANGUAGE ID not a number”错误,点击这个错误,定位到代码这一行“LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED”,把这一行删除,重新编译即可。
方法2.哪个项目出现这个错误,就到那个项目下找到“.rc”文件,然后查看这个rc文件的代码,把“XXXXX”类型资源相关的段的代码都删除即可。