一、WEBKIT MODULE总是不在编译列表中(即使configure时指定webkit)
{命令行下g++ -dumpversion > 4,适用下列解决方法}:将下列代码中4*|3.4*)改为9*|8*|7*|6*|5*|4*|3.4*)
case "$XPLATFORM" in
*-g++*)
case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in #QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`
4*|3.4*)
;;
3.3*)
canBuildWebKit="no"
;;
*)
canBuildWebKit="no"
canBuildQtXmlPatterns="no"
;;
esac
解析:读configure文件找问题所在:
1.configure时输出是由下列语句控制
case "$CFG_WEBKIT" in
yes) echo "WebKit module .......... yes" ;;
debug) echo "WebKit module .......... yes (debug)" ;;
no) echo "WebKit module .......... no" ;;
#####其中 $CFG_WEBKIT = no
2.$CFG_WEBKIT=no是由于:
if [ "$CFG_WEBKIT" != "no" ]; then
CFG_WEBKIT="$canBuildWebKit"
fi
#####其中 $canBuildWebKit = no
3.$canBuildWebKit = no是由于:
case "$XPLATFORM" in #XPLATFORM= # This seems to be the QMAKESPEC, like "linux-g++"
or "symbian-gcce" ##echo $XPLATFORM linux-g++
*-g++*)
# Check gcc's version
case "$(${QMAKE_CONF_COMPILER} -dumpversion)" in #QMAKE_CONF_COMPILER=`getXQMakeConf QMAKE_CXX`
4*|3.4*)
;;
3.3*)
canBuildWebKit="no"
;;
*)
canBuildWebKit="no"
canBuildQtXmlPatterns="no"
;;
esac
其中getXQMakeConf()
{
` getQMakeConf1 "$XQMAKESPEC/qmake.conf" | getQMakeConf2`
getQMakeConf3 "$1" "$xspecvals"
}
将mkspecs目录下编译器环境(linux-g++)对应的qmake.conf加载,寻找$1(QMAKE_CXX)等于的值,即QMAKE_CXX = g++中的 g++,QMAKE_CONF_COMPILER=g++,$(${QMAKE_CONF_COMPILER} -dumpversion)为“7” ,导致canBuildWebKit="no",CFG_WEBKIT="no"
可见上述写法是不友好的,作者只是基于当时最新的gcc版本,此处将4*|3.4*)改为9*|8*|7*|6*|5*|4*|3.4*)##我也不友好一把
编译得到:WebKit module .......... yes ##问题解决!
二、api/qcoloroutput_p.h:74:60: 错误:shift expression ‘(1048575 << 20)’ overflows [-fpermissive]
解决:api/qcoloroutput_p.h中修改:ForegroundMask = 0x1f << ForegroundShift BackgroundMask = 0x7 << BackgroundShift
解析:
读api/qcoloroutput_p.h:
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
ForegroundMask = ((1 << ForegroundShift) - 1) << ForegroundShift,
BackgroundMask = ((1 << BackgroundShift) - 1) << BackgroundShift
读qcoloroutput.cpp中使用BackgroundMask只有:
const int backgroundCode = (int(color) & BackgroundMask) >> BackgroundShift;
const int foregroundCode = (int(color) & ForegroundMask) >> ForegroundShift;
finalMessage.append(ColorOutputPrivate::escapeCode(QLatin1String(ColorOutputPrivate::foregrounds[foregroundCode - 1])));
finalMessage.append(ColorOutputPrivate::escapeCode(QLatin1String(ColorOutputPrivate::backgrounds[backgroundCode - 1])));
其中,foregrounds数组下标0-15,backgrounds数组下标0-6,存储ANSI控制码以控制颜色,也就是ForegroundMask本意是取color的11至15位(虽然4位二进制最大为31,可能超出数组下标,但网络某api/qcoloroutput_p.h版本没有考虑这点,应是color参数有所控制,最大为16),BackgroundMask是取color的21至23位,按照本意,我们将qccoloroutput_p.h中ForegoundMask/BackgroundMask改为ForegroundMask = 0x1f << ForegroundShift BackgroundMask = 0x7 << BackgroundShift
三、
In file included from ../3rdparty/javascriptcore/JavaScriptCore/wtf/FastAllocBase.h:84:0,
from ../3rdparty/javascriptcore/JavaScriptCore/wtf/Vector.h:24,
from ../3rdparty/javascriptcore/JavaScriptCore/pcre/pcre_exec.cpp:50:
../3rdparty/javascriptcore/JavaScriptCore/wtf/TypeTraits.h:173:69: 错误:‘std::tr1’尚未声明
template<typename T> struct HasTrivialConstructor : public std::tr1::has_trivial_constructor<T> { };
###C++ tr1是针对C++标准库的第一次扩展,本身并非标准
解决:将
#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600))
#include <type_traits>
#endif
改为:
#if (defined(__GLIBCXX__) && (__GLIBCXX__ >= 20070724) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || (defined(_MSC_VER) && (_MSC_VER >= 1600))
#include <tr1/type_traits>
#endif
使用tr1目录下的type_traits而不是tr1父目录下的type_traits(后者搜索路径占优势)
四、
../3rdparty/javascriptcore/JavaScriptCore/wtf/HashTable.h:272:89: 错误:调用重载的‘swap(std::pair<QTWTF::RefPtr<QTJSC::UStringImpl>, QTJSC::SymbolTableEntry>&, std::pair<QTWTF::RefPtr<QTJSC::UStringImpl>, QTJSC::SymbolTableEntry>&)’有歧义
template<typename T> struct Mover<T, true> { static void move(T& from, T& to) { swap(from, to); } };
解决:
mkspecs\linux-g++\qmake.conf to add the -std=gnu++98 option to C++ builds:
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -std=gnu++98
解析:
读HashTable.h:
using std::swap;
#if !COMPILER(MSVC) && !OS(QNX) && !defined(_LIBCPP_VERSION)
// The Dinkumware C++ library (used by MSVC and QNX) and clang's libc++ have a swap for pairs defined.
// swap pairs by component, in case of pair members that specialize swap
template<typename T, typename U> inline void swap(pair<T, U>& a, pair<T, U>& b)
{
swap(a.first, b.first);
swap(a.second, b.second);
}
#endif
template<typename T, bool useSwap> struct Mover;
template<typename T> struct Mover<T, true> { static void move(T& from, T& to) { swap(from, to); } };
在T为pair时,HashTable.h中的swap与“using std::swap”导入的stl_pair.h中的swap有歧义,应是JavaScriptCore考虑gcc没有pair的swap。但
stl_pair.h中的swap在C++11下有效:
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
// Constrained free swap overload, see p0185r1
typename enable_if<__and_<__is_swappable<_T1>,
__is_swappable<_T2>>::value>::type
#else
void
#endif
swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y)
noexcept(noexcept(__x.swap(__y)))
{ __x.swap(__y); }
#if __cplusplus > 201402L || !defined(__STRICT_ANSI__) // c++1z or gnu++11
template<typename _T1, typename _T2>
typename enable_if<!__and_<__is_swappable<_T1>,
__is_swappable<_T2>>::value>::type
swap(pair<_T1, _T2>&, pair<_T1, _T2>&) = delete;
#endif
#####你在逗我吗
所以禁用C++11特性:
mkspecs\linux-g++\qmake.conf to add the -std=gnu++98 option to C++ builds:
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS -std=gnu++98
未足之处,一起交流吧!