2010年07月15日
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-angstro
m-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-l
inux-gnueabi/4.1.2/../../../../arm-angstrom-linux-g nueabi/bin/ld:
warning: libts-0.0.so.0, needed by
/home/stillwater/4.1.2/qt-everywhere-opensource-sr
c-4.6.0/lib/libQtGui.so, not found (try using -rpath or -rpath-link)
/home/stillwater/4.1.2/qt-everywhere-opensource-sr c-4.6.0/lib/libQtGui.so: undefined reference to `ts_read_raw'
/home/stillwater/4.1.2/qt-everywhere-opensource-sr c-4.6.0/lib/libQtGui.so: undefined reference to `ts_open'
/home/stillwater/4.1.2/qt-everywhere-opensource-sr c-4.6.0/lib/libQtGui.so: undefined reference to `ts_fd'
/home/stillwater/4.1.2/qt-everywhere-opensource-sr c-4.6.0/lib/libQtGui.so: undefined reference to `ts_config'
/home/stillwater/4.1.2/qt-everywhere-opensource-sr c-4.6.0/lib/libQtGui.so: undefined reference to `ts_close'
/home/stillwater/4.1.2/qt-everywhere-opensource-sr c-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-s rc-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-s rc-4.6.0/demos'
make: *** [sub-demos-make_default-ordered] Error 2
解决办法:
修改qt-everywhere-opensource-src-4.6.0/mkspecs/qws/lin ux-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
参考:
/search?q=cache:3WzcJeRRj4sJ:nckuhuahua.pixnet.net
/blog/post/30066956+libQtGui.so:+undefined+referenc
e+to+%60ts_read%27&cd=3&hl=en&ct=clnk&client=icewea
sel-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:$PA TH
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-angstr
om-linux-gnueabi/include/c++:/usr/local/arm/4.1.2/a
rm-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_LIBR ARY_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/Messag e.aspx
阅读(3403) | 评论(0) | 转发(0) |