在移植QT5到 IMX6Q linux平台时,一次又一次的升级,带来了一些明显的性能提升,这说明在嵌入式上,QT底层对OpenGL egl 的优化做的越来越好,越来越兼容.在Qt5.1 - Qt5.2 的系列版本中qml部分和多媒体部分一直都没法成功的编译进去,只能编译qtbase. 而在qt5.3.1的时候按照QT 官方的arm编译指南,轻松的编译了能编译的每一个模块,当然,除了webkit这种变态的东西.
因为是官方的arm编译指南,所以什么configure脚本我就不写了,完全是按照官方的编译步骤. 虽说轻松编译,其实也不是一气呵成的,其中有些小的错误.经过修改源代码中的一些bug,完全可以编译成功;
多线程编译的log不怎么好看,主要的错误内容就是,在编译fontconfig时出现错误:FC_WEIGHT_ULTRABLACK 未申明,定位到文件qtbase/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp
static inline int weightFromFcWeight(int fcweight)
{ // Font Config uses weights from 0 to 215 (the highest enum value) while QFont ranges from
// 0 to 99. The spacing between the values for the enums are uneven so a linear mapping from
// Font Config values to Qt would give surprising results. So, we do a piecewise linear
// mapping. This ensures that where there is a corresponding enum on both sides (for example
// FC_WEIGHT_DEMIBOLD and QFont::DemiBold) we map one to the other but other values map
// to intermediate Qt weights.
const int maxWeight = 99;
int qtweight;
if (fcweight < 0) qtweight = 0;
else if (fcweight <= FC_WEIGHT_LIGHT) qtweight = (fcweight * QFont::Light) / FC_WEIGHT_LIGHT;
else if (fcweight <= FC_WEIGHT_NORMAL) qtweight = QFont::Light + ((fcweight - FC_WEIGHT_LIGHT) * (QFont::Normal - QFont::Light)) / (FC_WEIGHT_NORMAL - FC_WEIGHT_LIGHT);
else if (fcweight <= FC_WEIGHT_DEMIBOLD) qtweight = QFont::Normal + ((fcweight - FC_WEIGHT_NORMAL) * (QFont::DemiBold - QFont::Normal)) / (FC_WEIGHT_DEMIBOLD - FC_WEIGHT_NORMAL);
else if (fcweight <= FC_WEIGHT_BOLD) qtweight = QFont::DemiBold + ((fcweight - FC_WEIGHT_DEMIBOLD) * (QFont::Bold - QFont::DemiBold)) / (FC_WEIGHT_BOLD - FC_WEIGHT_DEMIBOLD);
else if (fcweight <= FC_WEIGHT_BLACK) qtweight = QFont::Bold + ((fcweight - FC_WEIGHT_BOLD) * (QFont::Black - QFont::Bold)) / (FC_WEIGHT_BLACK - FC_WEIGHT_BOLD);
else if (fcweight <= FC_WEIGHT_ULTRABLACK) qtweight = QFont::Black + ((fcweight - FC_WEIGHT_BLACK) * (maxWeight - QFont::Black)) / (FC_WEIGHT_ULTRABLACK - FC_WEIGHT_BLACK);
else qtweight = maxWeight;
return qtweight;
}
然而在对源代码进行文本搜索时,发现FC_WEIGHT_ULTRABLACK是定义了的,只是在对arm平台进行编译时,被条件编译的宏给排除出去了,才导致这样的错误的.所以这样其实这个问题就好解决了.下面是一种解决方法,或者更简单的,直接注释掉错误的部分也可以,因为这一块字体部分对实际使用没有影响.
patch:
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h@@ -339,8 +339,10 @@ # define Q_PROCESSOR_WORDSIZE __SIZEOF_POINTER__ # elif defined(_LP64) || defined(__LP64__) || defined(WIN64) || defined(_WIN64) # define Q_PROCESSOR_WORDSIZE 8-# else+# elif defined(QT_POINTER_SIZE) # define Q_PROCESSOR_WORDSIZE QT_POINTER_SIZE+# else+# define Q_PROCESSOR_WORDSIZE sizeof(void*) # endif #endif --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp+++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp@@ -61,6 +61,10 @@ #include <fontconfig/fcfreetype.h> #endif +#ifndef FC_WEIGHT_ULTRABLACK+#define FC_WEIGHT_ULTRABLACK FC_WEIGHT_BLACK+#endif+ QT_BEGIN_NAMESPACE static inline bool requiresOpenType(int writingSystem)