Wednesday, September 10, 2008

WinCE 5.0 bug on persistent storage

The files in the recycle bin can not be restored after a hard reset. It is a Microsoft bug.

交叉编译qt-embedded-free-3.3.8 (转贴)

我是用qt-embedded-free-3.3.4


交叉编译环境:
HOST操作系统:Linux-2.6.15-1.2054_FC5-GCC版本-4.1.0
TARGET:mx31开发板(freescale-ARM11平台)
交叉编译工具链:arm-none-linux-gnueabi(mx31开发板所提供) gcc-4.1.1
Qt/E版本:qt-embedded-free-3.3.8
(ps:HOST上已经编译过qt-embedded-free-3.3.8---gcc 4.1.0)

下面的过程是在HOST-PC上已经正确的安装了qt-embedded-free-3.3.8上进行的:

交叉编译的详细步骤:
第一步:下载qt-embedded-free-3.3.8并解压缩到自定义的目录下。

我的目录是
tar jxvf qt-embedded-free-3.3.8.tar.bz2
自动生成 /root/qt/qt-embedded-free-3.3.8
(注意:记得将你在HOST编译好的QT/E的目录下的bin文件里的moc和uic二进制文件copy到我们交叉编译的目录下的bin文件夹里-就是/root/qt/qt-embedded-free-3.3.8)

注:moc and uic 应该是由qt-x11-free-3.3.8编译生成的。因为我使用 qt-x11-free-3.3.4所以要

./configure -no-xft. 3.3.5 should not have such problem.



第二步:安装交叉编译工具链
这一步取决于你所使用的交叉编译工具链,我的是arm-none-linux-gnueabi(freescale的mx31开发板所提供)

安装完成后bin的目录是:
/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/bin

第三步:配置qmake(即指定交叉编译工具)
在mkspecs/qws/下建立arm-none-linux-gnueabi目录
cd /root/qt/qt-embedded-free-3.3.8
cd mkspecs/qws/
mkdir arm-none-linux-gnueabi

把mkspecs/qws/linux-arm-g++下的qmake.conf和qplatformdefs.h复制到mkspecs/qws/arm-none-linux-gnueabi目录下

然后修改qmake.conf文件,把文件里面的编译器指定为arm-none-linux-gnueabi

用arm-none-linux-gnueabi-gcc和arm-none-linux-gnueabi-g++替代以下的arm-linux-gcc和arm-linux-g++

QMAKE_CC = arm-linux-gcc
QMAKE_CXX = arm-linux-g++
QMAKE_LINK = arm-linux-g++
QMAKE_LINK_SHLIB = arm-linux-g++

第四步:环境变量的设置
export QTEDIR=/root/qt/qt-embedded-free-3.3.8
export QTDIR=$QTEDIR
export PATH=/opt/freescale/usr/local/gcc-4.1.1-glibc-2.4-nptl-6/arm-none-linux-gnueabi/bin:$PATH
export PATH=$QTDIR/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

第五步:config
./configure -xplatform qws/arm-none-linux-gnueabi -no-cups -no-stl -no-qvfb -depths 4,8,16,32 -qt-gif -embedded arm -disable-sql

注意:在configure的时候会出现一个警告
WARNING: Failure to find: .moc/release-static-mt-emb-x86/allmoc.cpp

关于这个问题官方已经给出答案,引用如下
This is not a problem. It happens everytime Qt/embedded is configured.
所以,这个警告可以不预理会。

第六步:make 或者是 make sub-src
make/make sub-src

注意:make的时候由于对于qt3的交叉编译工具的gcc版本问题而导致提示如下错误:

../include/qstring.h: In member function 'ushort& QChar::unicode()':
../include/qstring.h:199: error: cannot bind packed field
'((QChar*)this)->QChar::ucs' to 'ushort&'

解决办法:
打开src/tools/qglobal.h查看318-326行:
# if (defined(__arm__) || defined(__ARMEL__)) && !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((packed))
# if __GNUC__ == 3 && __GNUC_MINOR__ >= 4
# define Q_NO_PACKED_REFERENCE
# endif
# endif
# if !defined(__EXCEPTIONS)
# define Q_NO_EXCEPTIONS
# endif

修改如下:
# if (defined(__arm__) || defined(__ARMEL__)) && !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((packed))
# if __GNUC__ == 3 && __GNUC_MINOR__ >= 4
# define Q_NO_PACKED_REFERENCE
# endif
+# if __GNUC__ == 4 && __GNUC_MINOR__ >= 0
+# define Q_NO_PACKED_POINTERS
+# endif
# endif
# if !defined(__EXCEPTIONS)
# define Q_NO_EXCEPTIONS
# endif

打开src/include/qstring.h查看195-199行
ushort unicode() const { return ucs; }
#ifdef Q_NO_PACKED_REFERENCE
ushort &unicode() { return *(&ucs); }
#else
ushort &unicode() { return ucs; }
#endif

修改如下:
ushort unicode() const { return ucs; }
#ifdef Q_NO_PACKED_REFERENCE
ushort &unicode() { return *(&ucs); }
+#elif defined Q_NO_PACKED_POINTERS
+ ushort &unicode() { ushort& tmp = ucs; return tmp; }
#else
ushort &unicode() { return ucs; }
#endif

ps:+号表示修改的地方

接下来就是make clean
make

第七步 strip
交叉编译成功后在/lib文件夹下生成以下文件:
libqte-mt.so
libqte-mt.so.3
libqte-mt.so.3.3
libqte-mt.so.3.3.8

[root@localhost lib]# ls -l
lrwxrwxrwx 1 root root 18 09-05 17:25 libqte-mt.so -> libqte-mt.so.3.3.8
lrwxrwxrwx 1 root root 18 09-05 17:25 libqte-mt.so.3 -> libqte-mt.so.3.3.8
lrwxrwxrwx 1 root root 18 09-05 17:25 libqte-mt.so.3.3 -> libqte-mt.so.3.3.8
-rwxr-xr-x 1 root root 7091636 09-07 08:51 libqte-mt.so.3.3.8

我们先来查看文件信息:
[root@localhost lib]# file libqte-mt.so.3.3.8
libqte-mt.so.3.3.8: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), not stripped

此时显示的是not stripped,即没有经过strip。

[root@localhost lib]# arm-none-linux-gnueabi-strip libqte-mt.so.3.3.8

执行strip命令之后我们再次查看文件信息:
[root@localhost lib]# file libqte-mt.so.3.3.8
libqte-mt.so.3.3.8: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), stripped

此 时显示的是stripped,即已经strip。你会发现,strip之后libqte-mt.so.3.3.8发生明显变化的,不过在实际的开发过程 中,我们是不提倡这样做的,因为使用strip后,使用gdb时就无法获得调试信息了。故,在开发过程,我们为了方便以后的调试最好不要strip。

后 记:因为是初步交叉编译,所以触摸屏支持和字体库的添加,中文支持,如何添加wenquanyi字体等等,还有库的裁减都没有具体实现,不过完成后我会继 续写出来,与大家分享!另外,很多地方我懒得注释,因为很多知识都是交叉编译的基础只是,请读者自己理解!这也是一个学习的过程。