王紫璇火锅英雄中走光:Qt 4.6.0 嵌入式开发环境的搭建、移植

来源:百度文库 编辑:中财网 时间:2024/05/04 15:51:08
Qt:qt-everywhere-opensource-src-4.6.0.tar.gz
嵌入式平台:2440
arm-linux-gcc:4.1.2,下载(我用4.3.2和4.4.1版本时,移植时都有段错误。我把它放在:/usr/local/arm/4.1.2/ 。)

将 qt-everywhere-opensource-src-4.6.0.tar.gz 压缩包解压为3份,分别编译 PC ,嵌入式 x86 和 arm 三个版本。

1. 编译 PC 版:
$ ./configure
$ make
# make install

2. 编译嵌入式x86版:
$ ./configure -embedded x86 -qt-gfx-qvfb -qt-kbd-qvfb -qt-mouse-qvfb
$ make
# make install

编译安装PC版中的 qvfb:
$ cd ***/qt-everywhere-opensource-src-4.6.0/tools/qvfb
$ make
# cp ***/qt-everywhere-opensource-src-4.6.0/bin/qvfb /usr/local/Trolltech/QtEmbedded-4.6.0/bin


3. 编译嵌入式arm版(需要 arm-linux-gcc 的支持):

编译tslib对触摸屏支持:
下载,tslib1.4.tar.gz,解压后:
$ ./configure --prefix=/usr/local/tslib/ --host=arm-linux ac_cv_func_malloc_0_nonnull=yes
$ make
# make install

设置环境变量,以便编译时找到相关的库:
$ export CPLUS_INCLUDE_PATH=/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++:/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++/arm-angstrom-linux-gnueabi

配置:
$ ./configure \
-opensource \
-confirm-license \
-release -shared \
-embedded arm \
-xplatform qws/linux-arm-g++ \
-depths 16,18,24 \
-fast \
-optimized-qmake \
-pch \
-qt-sql-sqlite \
-qt-libjpeg \
-qt-zlib \
-qt-libpng \
-qt-freetype \
-little-endian -host-little-endian \
-no-qt3support \
-no-libtiff -no-libmng \
-no-opengl \
-no-mmx -no-sse -no-sse2 \
-no-3dnow \
-no-openssl \
-no-webkit \
-no-qvfb \
-no-phonon \
-no-nis \
-no-opengl \
-no-cups \
-no-glib \
-no-xcursor -no-xfixes -no-xrandr -no-xrender \
-no-separate-debug-info \
-nomake examples -nomake tools -nomake docs \
-qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib

配置结果:
Debug ............... no
Qt 3 compatibility .. no
QtDBus module ....... no
QtConcurrent code.... yes
QtScript module ..... yes
QtScriptTools module yes
QtXmlPatterns module no
Phonon module ....... no
Multimedia module ... yes
SVG module .......... yes
WebKit module ....... no
Declarative module .. no
STL support ......... no
PCH support ......... yes
MMX/3DNOW/SSE/SSE2.. no/no/no/no
iWMMXt support ...... no
IPv6 support ........ yes
IPv6 ifname support . yes
getaddrinfo support . yes
getifaddrs support .. yes
Accessibility ....... yes
NIS support ......... no
CUPS support ........ no
Iconv support ....... no
Glib support ........ no
GStreamer support ... auto
Large File support .. yes
GIF support ......... plugin
TIFF support ........ no
JPEG support ........ plugin (qt)
PNG support ......... yes (qt)
MNG support ......... no
zlib support ........ yes
Session management .. no
Embedded support .... arm
Freetype2 support ... yes
Graphics (qt) ....... linuxfb multiscreen
Graphics (plugin) ...
Decorations (qt) .... styled windows default
Decorations (plugin)
Keyboard driver (qt). tty
Keyboard driver (plugin)
Mouse driver (qt) ... pc linuxtp tslib
Mouse driver (plugin)
OpenGL support ...... no
OpenVG support ...... no
SQLite support ...... qt (qt)
OpenSSL support ..... no
alsa support ........ yes

编译:$ make

如果出错:
/usr/local/arm/4.1.2/bin/../lib/gcc/arm-angstrom-linux-gnueabi/4.1.2/../../../../arm-angstrom-linux-gnueabi/bin/ld: warning: libts-0.0.so.0, needed by /home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so, not found (try using -rpath or -rpath-link)
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_read_raw'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_open'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_fd'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_config'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_close'
/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/lib/libQtGui.so: undefined reference to `ts_read'
collect2: ld returned 1 exit status
make[2]: *** [deform] Error 1
make[2]: Leaving directory `/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/demos/deform'
make[1]: *** [sub-deform-make_default] Error 2
make[1]: Leaving directory `/home/stillwater/4.1.2/qt-everywhere-opensource-src-4.6.0/demos'
make: *** [sub-demos-make_default-ordered] Error 2

解决办法:
修改qt-everywhere-opensource-src-4.6.0/mkspecs/qws/linux-arm-g++/qmake.conf 文件(添加lts参数):
QMAKE_CC = arm-linux-gcc -lts
QMAKE_CXX = arm-linux-g++ -lts
QMAKE_LINK = arm-linux-g++ -lts
QMAKE_LINK_SHLIB = arm-linux-g++ -lts

参考:http://74.125.153.132/search?q=cache:3WzcJeRRj4sJ:nckuhuahua.pixnet.net/blog/post/30066956+libQtGui.so:+undefined+reference+to+%60ts_read%27&cd=3&hl=en&ct=clnk&client=iceweasel-a

添加环境变量:# export PATH=/usr/local/arm/4.1.2/bin:$PATH

安装:# make install-strip

安装完成后,在 /usr/local/Trolltech 目录中有三个文件夹:Qt-4.6.0、QtEmbedded-4.6.0、QtEmbedded-4.6.0-arm。

测试嵌入式 x86 :
$ source ~/.setenv-qt-x86.sh
$ qvfb -width 800 -height 600 &
$ /usr/local/Trolltech/QtEmbedded-4.6.0/demos/books/books -qws

4、编写环境变量设置文件(方便不同环境切换):

PC 机的~/.bashrc 中添加:
export PATH=$PATH:/usr/local/arm/4.1.2/bin

~/.setenv-qt-x11.sh(对应于PC版Qt):
PATH=/usr/local/Trolltech/Qt-4.6.0/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.6.0/lib:$LD_LIBRARY_PATH
CPLUS_INCLUDE_PATH=

~/.setenv-qt-x86.sh:
QTEDIR=/usr/local/Trolltech/QtEmbedded-4.6.0
PATH=/usr/local/Trolltech/QtEmbedded-4.6.0/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.6.0/lib:$LD_LIBRARY_PATH

~/.setenv-qt-arm.sh:
QTEDIR=/usr/local/Trolltech/QtEmbedded-4.6.0-arm
PATH=/usr/local/Trolltech/QtEmbedded-4.6.0-arm/bin:$PATH
LD_LIBRARY_PATH=/usr/local/Trolltech/QtEmbedded-4.6.0-arm/lib:$LD_LIBRARY_PATH
CPLUS_INCLUDE_PATH=/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++:/usr/local/arm/4.1.2/arm-angstrom-linux-gnueabi/include/c++/arm-angstrom-linux-gnueabi:$CPLUS_INCLUDE_PATH

5、移植
将 PC 机上 /usr/local/Trolltech/QtEmbedded-4.6.0-arm/lib 中的库复制到2440的 /usr/local/Trolltech/QtEmbedded-4.6.0-arm/lib(对应目录复制)。

将 PC 机上 /usr/local/tslib 中的库复制到2440的 /usr/local 。

如果运行时还缺少其他的库,复制方法相同。

为支持触摸屏,开机自动设置环境变量,在2440的 /etc/profile中追加:
export LD_LIBRARY_PATH=/usr/local/lib:$QTDIR/lib:$LD_LIBRARY_PATH
export TSLIB_ROOT=/usr/local/lib
export TSLIB_TSDEVICE=/dev/input/event0
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_PLUGINDIR=/usr/local/lib/ts
export TSLIB_CONSOLEDEVICE=none
export TSLIB_CONFFILE=/usr/local/etc/ts.conf
export POINTERCAL_FILE=/etc/pointercal
export TSLIB_CALIBFILE=/etc/pointercal
export QWS_MOUSE_PROTO=Tslib:/dev/input/event0

注:可用$ cat /dev/input/event0 测试触摸屏

取消/usr/local/etc/ts.conf中的第一个注释:
# module_raw input (去掉#,并且该行顶格)

运行 /usr/local/bin/ts_calibrate 校正触摸屏。

6、程序编译:
PC版:
$ make distclean
$ source ~/.setenv-qt-x11.sh
$ qmake
$ make

arm 版:
$ make distclean
$ source ~/.setenv-qt-arm.sh
$ qmake
$ make

参考:
http://blog.ednchina.com/gurongjiang/352778/Message.aspx

Fedora12下搭建Qt Creator的ARM开发环境 并 移植Qt4.6.2到Micro2440(一)



Fedora12下搭建Qt CreatorARM开发环境 移植Qt4.6.2Micro2440(一)
参考:http://hi.baidu.com/jiyeqian/blog/item/f46d26a2ff3f7da6caefd0d6.htmlhttp://blog.csdn.net/dongliqiang2006/archive/2009/08/30/4500002.aspx
环境:虚拟机Fedora12(建议安装Vmware Tools,详细安装方法参照Vmware帮助文档),USB串口,minicom终端。(minicom经常打不开ttyUSB0设备,我的解决方法是,打不开时就将USB串口移除,运行minicom,然后再接上USB串口,此时运行minicom一般都能打开设备)
软件准备:http://qt.nokia.com/downloads-cn下载最新版的软件包,当前是:
用于 Linux/X11 32 Qt Creator 1.3.1 二进制软件包qt-creator-linux-x86-opensource-1.3.1.binhttp://qt.nokia.com/downloads/qt-creator-binary-for-linux-x11-32-bit
用于嵌入式 Linux Qt 4.6.2qt-everywhere-opensource-src-4.6.2.tar.gzhttp://qt.nokia.com/downloads/embedded-linux-cpp
http://hi.baidu.com/jiyeqian/blog/item/f46d26a2ff3f7da6caefd0d6.html下载arm920t-eabi.tgz(即arm-linux-gcc-4.1.2)(http://qtextended.org/downloads/toolchains/arm920t-eabi.tgz
http://www.arm9.net/download.asp下载Root_Qtopia,我用的是友善光盘里的root_qtopia-20100108.tar.gzhttp://www.arm123.com.cn/linux/root_qtopia-20100108.tar.gz
下载tslib1.4,这个忘了在哪下载的了,网上有很多,有些不能用,大家自己找个能用的吧。
*以下安装方法主要来自文章http://hi.baidu.com/jiyeqian/blog/item/f46d26a2ff3f7da6caefd0d6.html
qt-everywhere-opensource-src-4.6.2.tar.gz 压缩包解压为3份,分别编译 PC ,嵌入式 x86 arm 三个版本。
我在root目录下建立tmp文件夹,将qt-everywhere-opensource-src-4.6.2.tar.gz直接解压后复制2分,分别命名为pcx86arm

1. 编译 PC 版:进入pc目录#./configure# gmake# gmake install安装过程比较长,没有碰到过错误。
2. 编译嵌入式x86版:进入x86目录# ./configure -embedded x86 -qt-gfx-qvfb -qt-kbd-qvfb -qt-mouse-qvfb# gmake# gmake install安装过程比较长,没有碰到过错误。
编译安装PC版中的 qvfb进入pc/tools/qvfb/目录#make编译完毕,将pc/bin目录下的qvfb文件复制到/usr/local/Trolltech/QtEmbedded-4.6.2/bin目录。
3. 编译嵌入式arm版(需要 arm-linux-gcc 的支持):使用友善自带的ARM-Linux GCC 4.3.2编译完了,程序移植到开发板上后,出现Segmentation Fault错误,按原文,使用4.1.2正常。
直接将arm920t-eabi.tgz解压缩到根目录,不可以像文章中说的那样“我把它放在:/usr/local/arm/4.1.2/ ”,最起码我放过去后出错了。把编译器路径加入系统环境变量,运行命令: #gedit /root/.bashrc 编辑/root/.bashrc文件,在最后一行加上 export PATH=/opt/toolchains/arm920t-eabi/bin:$PATH

编译tslib对触摸屏支持:下载,tslib1.4.tar.gz,解压后:# ./configure --prefix=/usr/local/tslib/ --host=arm-linux ac_cv_func_malloc_0_nonnull=yes# make # make install我下载的包解压后没有configure文件,需要运行autogen.sh后才能生成。
设置环境变量,以便编译时找到相关的库:# export CPLUS_INCLUDE_PATH=/opt/toolchains/arm920t-eabi/arm-angstrom-linux-gnueabi/include/c++:/opt/toolchains/arm920t-eabi/arm-angstrom-linux-gnueabi/include/c++/arm-none-linux-gnueabi# export PATH=/opt/toolchains/arm920t-eabi/bin:$PATH
修改qt-everywhere-opensource-src-4.6.2/mkspecs/qws/linux-arm-g++/qmake.conf 文件(添加lts参数):QMAKE_CC                = arm-linux-gcc -ltsQMAKE_CXX               = arm-linux-g++ -ltsQMAKE_LINK              = arm-linux-g++ -ltsQMAKE_LINK_SHLIB        = arm-linux-g++ -lts这一步必须有,不然肯定出错。
配置:必须加上“-prefix /usr/local/Trolltech/QtEmbedded-4.6.2-arm ”参数, 不然安装后不在QtEmbedded-4.6.2-arm文件夹下,而是覆盖了QtEmbedded-4.6.2# ./configure \-prefix /usr/local/Trolltech/QtEmbedded-4.6.2-arm \
-opensource \-confirm-license \-release -shared \-embedded arm \-xplatform qws/linux-arm-g++ \-depths 16,18,24 \-fast \-optimized-qmake \-pch \-qt-sql-sqlite \-qt-libjpeg \-qt-zlib \-qt-libpng \-qt-freetype \-little-endian -host-little-endian \-no-qt3support \-no-libtiff -no-libmng \-no-opengl \-no-mmx -no-sse -no-sse2 \-no-3dnow \-no-openssl \-no-webkit \-no-qvfb \-no-phonon \-no-nis \-no-opengl \-no-cups \-no-glib \-no-xcursor -no-xfixes -no-xrandr -no-xrender \-no-separate-debug-info \-nomake examples -nomake tools -nomake docs \-qt-mouse-tslib -I/usr/local/tslib/include -L/usr/local/tslib/lib
上面划掉的蓝色内容,可以不要的,这样编辑也不会出错(虚拟机搞坏了,不得已重装,配置参数时忘了干上面的工作了,结果发现没出错)。

关于配置参数,参照一下这篇文章吧,可以用configure -embedded –help查看。

http://www.cuteqt.com/blog/?p=582

如果你放弃配置,则使用命令:# gmake confclean
编译:# gmake
安装:# gmake install
安装完成后,在 /usr/local/Trolltech 目录中有三个文件夹:Qt-4.6.2QtEmbedded-4.6.2QtEmbedded-4.6.2-arm
4、移植我是通过NFS启动的系统,具体操作可以参照友善的手册,在http://www.arm9.net/download.asp有下载,在第5.5.3节通过NFS启动系统。
Fedora12  /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib 中的所有文件复制到/opt/FriendlyARM/mini2440/root_qtopia/usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib目录中(对应目录复制,相当于复制到了开发板对应目录中),其实需要的时候可以裁剪,看原文吧。
Fedora12  /usr/local/tslib 中的库复制到/opt/FriendlyARM/mini2440/root_qtopia/usr/local中。即将/usr/local/tslib下的所有文件复制到/opt/FriendlyARM/mini2440/root_qtopia/usr/local文件夹下。
如果运行时还缺少其他的库,复制方法相同。也可以使用arm-angstrom-linux-gnueabi-readelf -a 程序名 | grep "Share",命令查看需要哪些共享库,一起复制过去。
为支持触摸屏,开机自动设置环境变量,在2440 /etc/profile中追加:export LD_LIBRARY_PATH=/usr/local/lib:$QTDIR/lib:$LD_LIBRARY_PATH                                                  export TSLIB_ROOT=/usr/local/lib     export TSLIB_TSDEVICE=/dev/input/event0export TSLIB_FBDEVICE=/dev/fb0  export TSLIB_PLUGINDIR=/usr/local/lib/tsexport TSLIB_CONSOLEDEVICE=noneexport TSLIB_CONFFILE=/usr/local/etc/ts.confexport POINTERCAL_FILE=/etc/pointercalexport TSLIB_CALIBFILE=/etc/pointercalexport QWS_MOUSE_PROTO=Tslib:/dev/input/event0
取消/usr/local/etc/ts.conf中的第一个注释:# module_raw input (去掉#,并且该行顶格)我编辑时没有“#
启动Micro2440运行 /usr/local/bin/ts_calibrate 校正触摸屏。
到此Qt4.6.2的移植暂告一段落,移植还没有完,此时如果在开发板上运行Qt4.6.2-arm编译的程序,则会出现“relocation error: /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/libQtGui.so.4: symbol powf, version GLIBCXX_3.4 not defined in file libstdc++.so.6 with link time reference”错误。
今天晚了,明天继续奉上……