1、系统环境以及软件准备
主机操作系统: 9.04
主机编译器:gcc version 4.3.3 ( 4.3.3-5ubuntu4)
交叉编译器:arm-linux-gcc 3.4.1
软件安装包:(软件包事先下载到了主目录下的Qt目录)
qt-everywhere-opensource-src-4.6.2.tar.gz (适合 x11 ,embedded)
2.下载qt-everywhere-opensource-src-4.6.2.tar.gz
下载地址:下载
3.安装qt-x11(主要是为了得到assistant ,designer ,qvfb,uic 等工具)
A、编译安装qt-x11到/usr/local/qt-x86目录
解压:tar xzvf qt-everywhere-opensource-src-4.6.2.tar.gz
进入解压目录: cd qt-everywhere-opensource-src-4.6.2
配置:./configure -prefix /usr/local/qt-x86 -qvfb
编译:make
安装: make install
NOTE: 配置时要加上 -qvfb ,否则后面无法编译生成 qvfb(Qt/Embedded Virtual Framebuffer) 工具
B、编译安装qvfb
进入qvfb源文件目录:cd qt-everywhere-opensource-src-4.6.2/tools/qvfb/
编译:make
安装:sudo make install
然后将
完成后会在/usr/local/qt-x86/bin 里找到 qvfb
4.编译安装qt-embedded
这里要编译qte的两个版本,qte for x86 (主要是生成在x86体系结构(即开发主机上)通过qvfb 运行的工具和库文件),
qte for arm(主要是生成在arm体系结构(即开发板上)直接运行的工具和库文件)
qte for x86 :
A、解压qt-everywhere-opensource-src-4.6.2.tar.gz
解压:tar xzvf qt-everywhere-opensource-src-4.6.2.tar.gz
B,进入刚才解压得到的目录
cd qt-everywhere-opensource-src-4.6.2
C,编译并安装 qte-for x86(在 /usr/local/qte-x86下生成 一些工具和相应的库文件)
配置:./configure -prefix /usr/local/qte-x86 -qvfb -qt3support
-debug-and-release -system-zlib -system-libtiff -system-libpng
-system-libjpeg -qt-libmng -make libs -nomake examples -nomake demos
-nis -no-cups -xplatform qws/linux-x86-g++ -embedded x86 -depths
16,24,32 -qt-gfx-qvfb -no-gfx-linuxfb -no-gfx-transformed -no-gfx-vnc
-no-gfx-multiscreen -plugin-sql-sqlite -no-glib -dbus -qt-kbd-qvfb
-qt-mouse-qvfb
(原先编译了 examples, demos 的,但一直出现错误,才有了后面列的几个错误,最后遇到一个错误解决不了了,就去掉了那两个模块,但现在qvfb还是有问题,有两个鼠标,一个一直飘,)
相关参数可以 用 ./configure -help 查看,感觉Qt3 和Qt4 的配置参数还是有点区别的,第一次我加了 -qt-mouse-usb 报告说 不识别这个参数。
编译:make
安装:make install
(安装完成后就会在 /usr/local/qte-x86下生成 一些工具和相应的库文件,当然可以改 -prefix yourDIR 不加 这个参数会默认安装在 /usr/local/Trolltech/***)
qte for arm:
可以把刚才解压的目录改名或者删除(如果没有足够空间的话)
A、解压qt-everywhere-opensource-src-4.6.2.tar.gz
解压:tar xzvf qt-everywhere-opensource-src-4.6.2.tar.gz
B,进入刚才解压得到的目录
cd qt-everywhere-opensource-src-4.6.2
C,编译并安装 qte-for arm(在 /usr/local/qte-arm下生成 一些工具和相应的库文件)
配置:./configure -prefix /usr/local/qte-arm -debug-and-release -qt3support -qt-zlib -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -make libs -nomake examples -nomake demos -nomake docs -no-cups -iconv -xplatform qws/linux-arm-g++ -embedded arm -little-endian -qt-freetype -depths 8,16,24,32 -qt-gfx-linuxfb -no-gfx-transformed -no-gfx-qvfb -no-gfx-vnc -no-gfx-multiscreen -no-dbus -qt-sql-sqlite -qt-kbd-qvfb -qt-kbd-tty -qt-mouse-pc -no-glib -qt-mouse-tslib -I/arm2410s/buildTSlib/include -L/arm2410s/buildTSlib/lib -D__ARM_ARCH_5TEJ__
(最后的参数 -D__ARM_ARCH_5TEJ__ 是出现了后面的第七个错误 #error "Not supported ARM architecture" 后又重新回来加上的,加上后指明了适合的平台就没这个错误了)
参数 -qt-mouse-tslib -I/arm2410s/buildTSlib/include -L/arm2410s/buildTSlib/lib 是说我用的是tslib,后面的-I ,-L 分别指明了要包含的头文件和库文件, /arm2410s/buildTSlib/是我编译tslib-1.0是生成文件的目录。
编译:make
安装:make install
5.设置环境变量
A:针对 qte for x86的
cd /usr/local/
vi setenv-x86
编辑完后的内容如下:
export QT4DIR=/usr/local/qt-x86
export QTEDIR=/usr/local/qte-x86
export PATH=$QTEDIR/bin:$QT4DIR/bin:$PATH
export LD_LIBRARY_PATH=$QT4DIR/lib:$QTEDIR/lib:$LD_LIBRARY_PATH
保存退出
B:针对 qte for arm的
vi setenv-arm
编辑完后的内容如下:
export QT4DIR=/usr/local/qt-x86
export QTEDIR=/usr/local/qte-arm
export PATH=$QTEDIR/bin:$QT4DIR/bin:$PATH
export LD_LIBRARY_PATH=$QT4DIR/lib:$QTEDIR/lib:$LD_LIBRARY_PATH
保存并退出
要运行哪个版本就设置相应的环境,如要在主机上用qvfb ,就用 运行:. setenv-x86 (注意点后面有个空格)
6.依旧存在的问题:
A.下面所列第5个错误没有解决,哎,没有坚持下去,就转不编译 例子和演示了。
B.编译出来的qvfb 里有2个鼠标,一个飘忽不定。还没找到解决方法。
C.qt3和qt4 的兼容性还是有问题,虽然我编译了 qt3support ,也利用qt3to4 加以转换,但编译时还是有很多问题,这是我接下来要做的主要事情,我在qt3.3.8下本来用得很好的,但做的一个程序在开发板上跑步起来,就是绿屏和一 个鼠标,但串口输出的调试信息是正确的,且在qvfb上可以正常运行,这个问题至今一直困惑着我。
7.编译过程中可能出现的错误和部分解决办法
1:error
/usr/bin/ld: cannot find -lXtst
collect2: ld returned 1 exit status
make: *** [../../bin/qvfb] Error 1
解决:
sudo apt-get install libxtst-dev
2:error
qtiffhandler.cpp:48:20: error: tiffio.h: No such file or directory
解决:cp /usr/local/qt4.6-x86/src/3rdparty/libtiff/libtiff/tiffio.h /usr/local/qt4.6-x86/src/plugins/imageformats/tiff
3:error
In file included from qtiffhandler.cpp:48:
tiffio.h:33:18: error: tiff.h: No such file or directory
解决:cp /usr/local/qt4.6-x86/src/3rdparty/libtiff/libtiff/tiff.h /usr/local/qt4.6-x86/src/plugins/imageformats/tiff
4:error
/usr/bin/ld: cannot find -ltiff
解决:apt-get install libtiff4-dev
5:error
/usr/bin/ld: cannot find -lQtUiTools
collect2: ld returned 1 exit status
悬而未决
6:error
QFontEngineFT::init(QFontEngine::FaceId, bool, QFontEngineFT::GlyphFormat)':
text/qfontengine_ft.cpp:696: warning: initialization to `int' from `qreal'
text/qfontengine_ft.cpp:696: warning: argument to `int' from `qreal'
{standard input}: Assembler messages:
{standard input}:1587: Error: register or shift expression expected -- `orr r3,r2,lsl#16'
{standard input}:1597: Error: register or shift expression expected -- `orr r2,r3,lsl#16'
{standard input}:3206: Error: register or shift expression expected -- `orr r3,r1,lsl#16'
{standard input}:3219: Error: register or shift expression expected -- `orr r3,ip,lsl#16'
临时解决方案:
To fix this issue patch /src/3rdparty/freetype/include/freetype/config/ftconfig.h Line 330.
(原来的为) "orr %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
(修改后为) "orr %0, %0, %2, lsl #16\n\t" /* %0 |= %2 << 16 */
7:error
In file included from ./config.h:26,
from ../JavaScriptCore/pcre/pcre_compile.cpp:44:
../JavaScriptCore/wtf/Platform.h:338:6: #error "Not supported ARM architecture"
make[1]: *** [obj/release/pcre_compile.o] Error 1
make[1]: Leaving directory `/usr/local/qte4.6-arm/src/3rdparty/webkit/WebCore'
make: *** [sub-webkit-make_default-ordered] Error 2
解决如下:
Maybe it's late for a reply but I have a detailed solution to the problem.
Like what people have mentioned in the replies,
you have to specify the target architecture.
Check /3rdparty/javascriptcore/JavaScriptCore/wtf/Platform.h
You will find the defintions for the architectures there.
such as , "__ARM_ARCH_5TEJ__" (this is for ARMv5)
add a line in your ./configure parameters, such as "-D__ARM_ARCH_5TEJ__" , or whichever architecture definition that suits the platform.
The compile problems to do with javascriptcore should go away.
It happened to work for me, at least for qt 4.5.1 and 4.6.2, for ARMv5 architecture.
Hope this helps.