vs2012 编译 Qt 4.8.4

Qt4.8.4 添加了 vs2012 的 makespace, 编译Qt方便多了。但据说对于webkit vs2012不支持,有错误。所以我在编译中去掉了webkit.  如果使用到webkit,可以试下,看看能不能简单修改代码通过编译。

使用vs2012的cmd, 基于编译目标, 使用x86 或者 x64 的cmd, 修改QTDIR目录, 运行一下脚本:

 

set QTDIR=E:\devsoftware\qt-everywhere-opensource-src-4.8.4-amd64
set QMAKESPEC=win32-msvc2012
set PATH=%PATH%;%QTDIR%\bin
cd %QTDIR%
configure.exe  -debug-and-release -opensource -fast -no-qt3support -qt-zlib -mp -no-webkit
y
nmake -i

 

编译时并行的,如果是用笔记本,非商业散热设计的话,最好用鲁大师控制下Cpu最高温度,节能降温:)。

nmake使用 -I 参数忽略错误,避免卡主编译过程

***************************************************************************************************************************************

最后附上 vs2012 编译 Qt 4.8.3的过程, 看别人文章的笔记,记不得出处了
1. 建立环境变量
call "E:\devsoftware\VS2012\VC\vcvarsall.bat" amd64
set QMAKESPEC=win32-msvc2010
set QTDIR=E:\devsoftware\qt-everywhere-opensource-src-4.8.3-vs2012-amd64
set PATH=%PATH%;E:\devsoftware\qt-everywhere-opensource-src-4.8.3-vs2012-amd64\bin

2. 修改 mkspecs\win32-msvc2010\qmake.conf
将 QMAKE_COMPILER_DEFINES  += _MSC_VER=1600 WIN32 当中的1600改成1700
QMAKE_CFLAGS            = -nologo -Zm200 -Zc:wchar_t-
改为
QMAKE_CFLAGS            = -nologo -Zm200 -Zc:wchar_t

3.  在控制台中,切换到Qt的安装目录下。使用如下参数进行配置
configure.exe  -debug-and-release -opensource -fast -no-qt3support -qt-zlib -mp

4. 修改代码错误 1
.\wtf/HashSet.h(180) : error C2664: 'std::pair<_Ty1,_Ty2>::pair(const std::pair<_Ty1,_Ty2> &)' : cannot convert parameter 1 from 'std::pair<_Ty1,_Ty2>' to 'const std::pair<_Ty1,_Ty2> &'
在Qt的Src目录搜索这个HashSet.h

E:\devsoftware\qt-everywhere-opensource-src-4.8.3-vs2012-amd64\src\3rdparty\webkit\Source\JavaScriptCore\wtf

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);
}
将180行所在的函数以及它下面的函数用下面的代码替换:
template<typename T, typename U, typename V>
inline pair<typename HashSet<T,U,V>::const_iterator, bool> HashSet<T,U,V>::add(const ValueType &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;
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);
}

5. 修改代码错误 2
platform\DefaultLocalizationStrategy.cpp(327) : error C2001: newline in constant
platform\DefaultLocalizationStrategy.cpp(327) : fatal error C1057: unexpected end of file in macro expansion
这个错误的原因是因为代码里面的非英文的引号造成的。
E:\devsoftware\qt-everywhere-opensource-src-4.8.3-vs2012-amd64\src\3rdparty\webkit\Source\WebCore\platform

原始的错误代码如下:

return WEB_UI_STRING("Look Up “<selection>”", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));

大家注意 <selection> 单词前后的引号。就是它造成编译报错。修改成下面的代码

return WEB_UI_STRING("Look Up \"<selection>\"", "Look Up context menu item with selected word").replace("<selection>", truncatedStringForLookupMenuItem(selectedString));

6. nmake -i 编译

5. 修改代码错误 1

转载自:http://blog.csdn.net/salmonrun/article/details/8298146

标签: none

添加新评论