/*2011.1.5-2011.1.6*/
/*qtopia-2.2.0到FL2440-I(s3c2440)移植*/
/*主机系统:ubuntu 10.10 主机gcc:4.4.5*/
/*目标板:FL2440-I 目标板系统:linux-2.6.22.6 */
/*交叉编译器:arm-linux-gcc-2.95.3 */
/*需要的软件资源:e2fsprogs-1.40.2.tar.gz jpegsrc.v6b.tar.gz zlib-1.2.3.tar.gz libpng-1.2.19-no-config.tar.gz qt-x11-2.3.2.tar.gz qtopia-free-src-2.2.0.tar.gz */
1.安装g++
sudo apt-get install g++
2.建立工作目录:
mkdir /home/arm/work/qt
cd /home/arm/work/qt
mkdir source armlib arminclude qtopia2
拷贝所有软件包到/home/arm/work/qt/source
3.编译e2fsprogs-1.39
tar zxvf e2fsprogs-1.40.2.tar.gz
cd e2fsprogs-1.40.2/
设置环境变量:
export PATH=/usr/local/arm/2.95.3/bin:$PATH
export CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc
sudo ./configure --enable-elf-shlibs --host=arm-linux --with-cc=/usr/local/arm/2.95.3/bin/arm-linux-gcc --with-linker=/usr/local/arm/2.95.3/bin/arm-linux-ld --prefix=/usr/local/arm/2.95.3/arm-linux
sudo make
出现错误:
make[2]: makeinfo: Command not found
(makeinfo有关信息:http://www.linux-ren.org/modules/wiki/index.php/Makeinfo)
解决办法:
sudo apt-get install texinfo
编译成功后,拷贝相关文件:
cp -r lib/uuid/ /home/arm/work/qt/arminclude/
cp lib/libuuid.so* /home/arm/work/qt/armlib/
cp lib/libuuid.a /home/arm/work/qt/armlib/
4.交叉编译jpeg库
tar zxvf qtopia-free-src-2.2.0.tar.gz
tar zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b/
设置环境变量:
export QTDIR=/home/arm/work/qt/source/qtopia-free-2.2.0/
export QTEDIR=/home/arm/work/qt/source/qtopia-free-2.2.0/qtopia
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/arm/2.95.3/bin:$PATH
export CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc
sudo ./configure --enable-shared
修改生成的Makefile:
prefix = /usr/local -> prefix = /home/arm/work/qt/source/qt-2.3.10
CC= gcc -> CC = /usr/local/arm/2.95.3/bin/arm-linux-gcc
AR= ar rc -> AR= /usr/local/arm/2.95.3/bin/arm-linux-ar rc
AR2= ranlib -> AR2= /usr/local/arm/2.95.3/bin/arm-linux-ranlib
cp jconfig.doc jconfig.h
建立qt-2.3.10目录:
mkdir /home/arm/work/qt/source/qt-2.3.10
cd /home/arm/work/qt/source/qt-2.3.10/
mkdir -p bin include lib man/man1
cd /home/arm/work/qt/source/jpeg-6b/
sudo make
sudo make install -lib
cp jpeglib.h jconfig.h jmorecfg.h /home/arm/work/qt/arminclude/
cp /home/arm/work/qt/source/qt-2.3.10/lib/libjpeg.so* /home/arm/work/qt/armlib/
cp /home/arm/work/qt/source/qt-2.3.10/lib/libjpeg.so* /usr/local/arm/2.95.3/arm-linux/lib/
5.编译zlib:
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3/
设置环境变量:
export LD_LIBRARY_PATH=/usr/local/arm/2.95.3/arm-linux/lib:$LD_LIBRARY_PATH
export PATH=/usr/local/arm/2.95.3/bin:$PATH
export CC=/usr/local/arm/2.95.3/bin/arm-linux-gcc
sudo ./configure -shared
修改Makefile:
CC= gcc -> CC = /usr/local/arm/2.95.3/bin/arm-linux-gcc
LDSHARED=gcc -shared -Wl,-soname,libz.so.1 -> LDSHARED=/usr/local/arm/2.95.3/bin/arm-linux-gcc -shared -Wl,-soname,libz.so.1
CPP=gcc -E -> CPP=/usr/local/arm/2.95.3/bin/arm-linux-gcc -E
AR= ar rc -> AR= /usr/local/arm/2.95.3/bin/arm-linux-ar rc
RANLIB=ranlib -> RANLIB=/usr/local/arm/2.95.3/bin/arm-linux-ranlib
prefix =/usr/local -> prefix =/usr/local/arm/2.95.3/arm-linux
sudo make
cp libz.so* /home/arm/work/qt/armlib/
cp *.h /home/arm/work/qt/arminclude/
cp libz.so* /usr/local/arm/2.95.3/arm-linux/lib/
cp *.h /usr/local/arm/2.95.3/arm-linux/include/
6.编译libpng库:
tar zxvf libpng-1.2.19-no-config.tar.gz
cd libpng-1.2.19/
cp scripts/makefile.linux ./Makefile
修改Makefile:
CC= gcc -> CC = /usr/local/arm/2.95.3/bin/arm-linux-gcc
AR_RC=ar rc -> AR_RC= /usr/local/arm/2.95.3/bin/arm-linux-ar rc
RANLIB=ranlib -> RANLIB=/usr/local/arm/2.95.3/bin/arm-linux-ranlib
prefix =/usr/local -> prefix =/usr/local/arm/2.95.3/arm-linux
sudo make
cp libpng12.so* /home/arm/work/qt/armlib/
cp libpng.a /home/arm/work/qt/armlib/
cp *.h /home/arm/work/qt/arminclude/
这里因为编译qtopia要用到X11的相关库文件,所以先安装X11
7.安装X11
(安装X11相关链接http://forum.ubuntu.org.cn/viewtopic.php?f=77&t=126029&start=0)
确认有安装tmake
sudo apt-get install tmake
确认有安装g++
sudo apt-get install g++
确认有安装X11运行库(下面的库不一定全用到,我参考了网上的一些文章,宁可多装不少装...)
sudo apt-get install x11proto-core-dev
sudo apt-get install libx11-dev
sudo apt-get install xlibs-static-dev
sudo apt-get install libxfont-dev
sudo apt-get install libxfontp-dev
sudo apt-get install x11proto-xext-dev
sudo apt-get install libxext-dev
sudo apt-get install libqt3-mt-dev
sudo apt-get install libmcrypt-dev libltdl3-dev libmcrypt4
sudo mv qt-x11-2.3.2.tar.gz /usr/local/
tar zxvf qt-x11-2.3.2.tar.gz
mv qt-2.3.2 qt
cd qt
su root /*进入root帐户*/
这里之所以进入root帐户是因为如果用sudo命令则当前用户下不管哪里export定义的语句都无效,才发现还有这一说,看来编程还是要root用户.
QTDIR=/usr/local/qt
PATH=$QTDIR/bin:$PATH
MANPATH=$QTDIR/doc/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QTDIR PATH MANPATH LD_LIBRARY_PATH
/*QTDIR -- 你安装Qt的路径
PATH -- 用来定位moc程序和其它Qt工具
MANPATH -- 访问Qt man格式帮助文档的路径
LD_LIBRARY_PATH -- 共享Qt库的路径 */
./configure -no-opengl
make
(make过程的一些错误处理可参看这里http://wenku.baidu.com/view/bd3c8f3a87c24028915fc3bf.html)
错误:
/usr/include/ft2build.h:56: fatal error: freetype/config/ftheader.h: No such file or directory
解决:
ln -s /usr/include/freetype2/freetype/ /usr/include/freetype
错误:
/usr/local/qt/include/qvaluestack.h:57: error: cannot convert ‘QValueListIterator<QString>’ to ‘const char*’ for argument ‘1’ to ‘int remove(const char*)’
解决:
这个错误是说,在文件qvaluestack.h的57行出错。改正方法是修改文件/usr/local/qt/include/qvaluestack.h的第57行,将remove( this->fromLast() );改为this->remove( this->fromLast() );
修改时可能要更改文件权限,变成可写的,即sudo chmod +w /usr/local/qt/include/qvaluestack.h
make -C tools/qvfb
mv tools/qvfb/qvfb bin
cp /usr/local/qt/bin/uic /home/arm/work/qt/source/qtopia-free-2.2.0/qt2/bin
8.编译qtopia
cd qtopia-free-2.2.0/
(1)修改文件qmake.conf:
sudo chmod +w qtopia/mkspecs/qws/linux-arm-g++/qmake.conf
sudo vi qtopia/mkspecs/qws/linux-arm-g++/qmake.conf
QMAKE_LIBS_QT = -lqte -> QMAKE_LIBS_QT = -lqte -lpng -lz -luuid -ljpeg
(2)支持鼠标:
sudo vi qtopia/src/qt/qconfig-qpe.h
注释以下:
/*#ifndef QT_NO_QWS_CURSOR
#define QT_NO_QWS_CURSOR
#endif
#ifndef QT_NO_QWS_MOUSE_AUTO
#define QT_NO_QWS_MOUSE_AUTO
#endif
#ifndef QT_NO_QWS_MOUSE_PC
#define QT_NO_QWS_MOUSE_PC
#endif*/
(3)cp qtopia/src/qt/qconfig-qpe.h qt2/src/tools/
cd qtopia/src/libraries/qtopia
cp custom-linux-ipaq-g++.cpp custom-linux-arm-g++.cpp
cp custom-linux-ipaq-g++.h custom-linux-arm-g++.h
(4)sudo vi /usr/local/arm/2.95.3/arm-linux/sys-include/linux/videodev.h
注释这一行:
/*#include <linux/version.h>*/
(5)设置环境变量:
export QTDIR=/home/arm/work/qt/source/qtopia-free-2.2.0/qt2/
export QPEDIR=/home/arm/work/qt/source/qtopia-free-2.2.0/qtopia/
export TMAKEDIR=/home/arm/work/qt/source/qtopia-free-2.2.0/tmake/
export TMAKEPATH=$TMAKEDIR/lib/qws/linux-arm-g++/
export PATH=/usr/local/arm/2.95.3/bin:$PATH
export LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/lib:$LD_LIBRARY_PATH:/usr/local/qt/lib/
(6)cd /home/arm/work/qt/source/qtopia-free-2.2.0/
配置:
sudo ./configure -qte "-embedded -xplatform linux-arm-g++ -qconfig qpe -no-qvfb -depths 8,16,24,32 -no-xft -system-jpeg -system-libpng -system-zlib -gif -thread -release -I/home/arm/work/qt/arminclude/ -L/home/arm/work/qt/armlib/ -lpng -lz -luuid -ljpeg" -qpe '-xplatform linux-arm-g++ -edition pda -displaysize 320x240 -I/home/arm/work/qt/arminclude/ -L/home/arm/work/qt/armlib/ -prefix=/home/arm/work/qt/qtopia2'
需要回答yes
(7)sudo make
首先是根据书上修改了这些(说是高版本编译器带来的问题):
默认当前目录为/home/arm/work/qt/source/qtopia-free-2.2.0/
<1>vi qt2/src/tools/qvaluestack.h
57行:remove( this->fromLast() ); -> this->remove( this->formLast() );
<2>vi qt2/src/kernel/qwindowsystem_qws.h
开头增加:
class QWSInputMethod;
class QWSGestureMethod;
<3>vi qtopia/src/libraries/qtopia/backend/event.cpp
419行: while ( !( i & day ) && i <= Event::SUN ) { -> while ( !( i & day ) && (int)i <= Event::SUN ) {
<4>vi qtopia/src/libraries/qtopia/qdawg.cpp
294行: QDawgPrivate::~QDawgPrivate() -> ~QDawgPrivate()
<5>vi qtopia/src/libraries/qtopia2/thumbnailview_p.h
81行: void ThumbnailItem::paintItem( QPainter*, const QColorGroup& ); -> void paintItem( QPainter*, const QColorGroup& );
<6>vi qtopia/src/libraries/qtopiapim/abtable_p.h
276行: QListViewItem* PhoneTypeSelector::addType(QListViewItem* prevItem, -> QListViewItem* addType(QListViewItem* prevItem,
<7>vi qtopia/src/libraries/qtopiapim/numberentry_p.h
106行: bool NumberEntryDialog::eventFilter(QObject *o, QEvent *e); -> bool eventFilter(QObject *o, QEvent *e);
<8>vi qtopia/src/libraries/mediaplayer/videoviewer.cpp
52行: SimpleVideoWidget::SimpleVideoWidget(QWidget *parent); -> SimpleVideoWidget(QWidget *parent);
<9>vi qtopia/src/applications/addressbook/ablabel.h
78行: bool AbLabel::decodeHref(const QString& href, ServiceRequest* req, QString* pm) const; -> bool decodeHref(const QString& href, ServiceRequest* req, QString* pm) const;
<10>vi qtopia/src/games/minesweep/minefield.h
105行: void MineField::setState( State st ); -> void setState( State st );
106行: void MineField::placeMines(); -> void placeMines();
<11>vi qtopia/src/settings/buttoneditor/buttoneditordialog.h
56行: ServiceRequest ButtonEditorDialog::actionFor(int cur) const; -> ServiceRequest actionFor(int cur) const;
<12>vi qtopia/src/settings/qipkg/packagewizard.h
106行: PackageItem* PackageWizard::current() const; -> PackageItem* current() const;
<13>vi qtopia/src/plugins/inputmethods/keyboard/keyboard.h
60行: KeyboardPicks::~KeyboardPicks(); -> ~KeyboardPicks();
<14>vi qtopia/src/plugins/decorations/polished/polished.h
58行: void PolishedDecoration::drawBlend( QPainter *, const QRect &r, const QColor &c1, const QColor&c2 ) const; -> void drawBlend( QPainter *, const QRect &r, const QColor &c1, const QColor&c2 ) const;
<15>vi qtopia/src/server/inputmethods.cpp
86行: IMToolButton::IMToolButton( QWidget *parent ) : QToolButton( parent ) -> IMToolButton( QWidget *parent ) : QToolButton( parent )
错误:
In file included from /usr/include/fcntl.h:252,
from ../../libraries/qtopia/qmemoryfile_unix.cpp:48:
In function ‘int open(const char*, int, ...)’,
inlined from ‘QMemoryFileData* QMemoryFile::openData(const QString&, int, uint)’ at ../../libraries/qtopia/qmemoryfile_unix.cpp:141:
/usr/include/bits/fcntl2.h:51: error: call to ‘__open_missing_mode’ declared with attribute error: open with O_CREAT in second argument needs 3 arguments
解决办法:
手动修改qtopia-2.2.0/qtopia/src/libraries/qtopia/qmemoryfile_unix.cpp 141行
将
if (!f)
f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY);
修改为
if (!f)
f = ::open(tmpFile.latin1(), O_CREAT | O_WRONLY, 0666);
(8)sudo make install
(9)将所有支持的库文件都放到qtopia2/lib/:
cp /home/arm/work/qt/armlib/*.so* /home/arm/work/qt/qtopia2/lib/
这里有个问题就是不知道哪里配置错了还是什么,qtopia2/lib/fonts/下没有字体文件,导致启动后无法显示任何字符,所以我将qtopia-free-2.2.0/qt2/lib/fonts/拷了过去:
cp -r /home/arm/work/qt/source/qtopia-free-2.2.0/qt2/lib/fonts/ /home/arm/work/qt/qtopia2/lib/fonts/
9.在开发板上运行qt
(1)先将qtopia2拷到开发板上
(2)建个脚本文件方便启动qt(假设qtopia2拷到了开发板的根目录/下)
vi qpe.sh
内容如下:
#!/bin/sh
export HOME=/root
export QTDIR=/qtopia2
export QPEDIR=/qtopia2
export QWS_DISPLAY=LinuxFb:/dev/fb0
export QWS_KEYBOARD="TTY:/dev/tty1"
export PATH=$QPEDIR/bin:$PATH
export LD_LIBRARY_PATH=$QPEDIR/lib:$LD_LIBRARY_PATH
mkdir /dev/input/
mknod /dev/input/mouse0 c 13 32
export QWS_MOUSE_PROTO="USB:/dev/input/mouse0"
$QPEDIR/bin/qpe &
(注:HOME=/root
这个目录qt会在其下生成配置文件夹Settings
mkdir /dev/input/
mknod /dev/input/mouse0 c 13 32
export QWS_MOUSE_PROTO="USB:/dev/input/mouse0"
这三行是针对鼠标设置)
(3)修改权限使该文件可运行:
chmod +w qpe.sh
(4)为了使qt可以使用鼠标,需要增加内核支持,usb鼠标移植方法如下:
我的内核是linux2.6.22.6,新内核的USB鼠标在内核drivers/hid/usbhid目录下,文件名:usbmouse.c,如果你需要对鼠标驱动修改就看这个文件,我的开发板暂时不需要对鼠标驱动定制特别的操作,于是在保证2410配置文件默认的情况下,make menuconfig然后选择 Device Drivers -->进入 选中HID Devices ---> 进入 USB HID Boot Protocol drivers ---> 看到 USB HIDBP Mouse (simple Boot) support,(同时还有usb键盘支持选项,要用usb键盘就选上它)选中它,如果没有出现该项说明你在上边的步骤中选中了其他多余项,可以根据打开的kconfig文件中看到。
(关于添加USB鼠标支持也可以看这里:http://hi.baidu.com/estellejiang/blog/item/65e1d8dd182ae7e277c6387a.html)
第一次启动qt后,串口输出这些:
Warning: Unable to open /usr/share/zoneinfo/zone.tab
Warning: Timezone data must be installed at /usr/share/zoneinfo/
Warning: TimeZone::data Can't create a valid data object for 'America/New_York'
Warning: Need to run firstuse
Warning: language message - en_US
Warning: and its not null
Warning: loading /qtopia/i18n/en_US/qt.qm
Warning: loading /qtopia/i18n/en_US/qpe.qm
Warning: loading /qtopia/i18n/en_US/libqpe.qm
Warning: loading /qtopia/i18n/en_US/libqtopia.qm
Warning: loading /qtopia/i18n/en_US/language.qm
Warning: loading /qtopia/i18n/en_US/timezone.qm
Warning: loading /qtopia/i18n/en_US/systemtime.qm
但是有个问题就是第一次启动配置的时候,需要连续配置2次才行,第1次配置完了之后又会重新跳回配置界面,第2次配置完后才进入正常界面.
参考链接:
开发板使用笔记之--交叉编译qtopia-free-2.2.0
http://bbs.witech.com.cn/archiver/?tid-395.html
QT/QTE 编译安装问题与解决之道
http://blog.csdn.net/lesky/archive/2008/03/09/2159938.aspx
qtopia移植笔记
http://www.cublog.cn/u3/94019/showart_1895212.html
ubuntu安装QtWvDialer-0.4.4成功拨号DWCL-390C
http://forum.ubuntu.org.cn/viewtopic.php?f=77&t=126029&start=0