详解QT安装全过程

移动开发
QT安装全过程是本文要介绍的内容,主要是来了解并学习QT的应用,本文主要是来学习QT安装过程,具体内容的实现来看本文详解。

QT安装全过程是本文要介绍的内容,主要是来了解并学习QT的应用,本文主要是来学习QT安装过程,具体内容的实现来看本文详解。

一、qt的源码编译

1、编译触摸屏软件tslib

解压tslib-1.4.tar.gz

  1. Tar-zxvftslib-1.4.tar.gz-C/usr/local  
  2. cdtslib  
  3. apt-getinstalllibtool  
  4. apt-getinstallautoconf  
  5. apt-getinstallg++ 

在tslib目录下

  1. ./autogen.sh  
  2. CC=arm-linux-gcc  
  3. ####echo"ac_cv_func_malloc_0_nonnull=yes">arm-linux.cache//###表示注释掉了,第三句是前两句的结合  
  4. ####./configure--prefix=/opt/ts/--host=arm-linux--cache-file=arm-linux.cache  
  5. ./configure--prefix=/opt/ts/--host=arm-linuxac_cv_func_malloc_0_nonnull=yes 

打开tests/ts_calibrate.c,修改两个open,加上第三个参数0//atline227229

  1. make  
  2. makeinstall 

2、安装qt--X11

  1. apt-getinstalllibX11-devlibXext-devlibXtst-dev  
  2. apt-getinstallxorg-dev 

解压tarzxvfqt-everywhere-opensource-src-4.6.3.tar.gz-C/usr/local/

  1. mvqt-everywhere-opensource-src-4.6.3qt-everywhere-opensource-src-4.6.3-x11  
  2. ./configure-nomakeexamples-nomakedemos  
  3. make&&makeinstall 

该过程会出现让你选择commercial或者open版本==》输入o

然后询问是否接受license==》输入yes

  1. make&&makeinstall 

//三个小时左右,该干嘛干嘛去

3、安装qt--x86

  1. #tarxzvfqt-everywhere-opensource-src-4.6.3.tar.gz-C/usr/local  
  2. #mvqt-everywhere-opensource-src-4.6.3qt-everywhere-opensource-src-4.6.3-x86  
  3. #cdqt-everywhere-opensource-src-4.6.3-x86  
  4. #./configure-prefix/usr/local/Trolltech/Qt-4.6.3-x86-nomakeexamples-nomakedemos  
  5. -nomakedocs-nomaketools-embeddedx86-qvfb  
  6. #make&&makeinstall 

4、安装qt--arm

  1. ./configure-prefix/usr/local/Trolltech/Qt-4.6.3-arm-release-shared-fast-xplatformqws/linux  
  2. -arm-g++-embeddedarm-depths16-no-qvfb-no-qt3support-qt-sql-sqlite-qt  
  3. -zlib-qt-libpng-qt-freetype-qt-mouse-tslib-no-mouse-pc-no-mouse-linuxtp  
  4. -nomakeexamples-nomakedemos-nomakedocs-nomaketools-I/opt/ts/include-L/opt/ts/lib 

有错,使用下面的

  1. ./configure\  
  2. -prefix/usr/local/Trolltech/Qt-4.6.3-arm\  
  3. -release-shared-fast\  
  4. -xplatformqws/linux-arm-g++-embeddedarm\  
  5. -depths16-no-qvfb\  
  6. -no-qt3support-qt-sql-sqlite-qt-zlib-qt-libpng-qt-freetype\  
  7. -qt-mouse-tslib-no-mouse-pc-no-mouse-linuxtp\  
  8. -nomakeexamples-nomakedemos-nomakedocs-nomaketools\  
  9. -I/opt/ts/include-L/opt/ts/lib 

执行完configure命令之后,还需要修改三个文件:

  1. cdqt-embeded-opensource-src-4.6.3-arm 

1)该目录下/src/3rdparty/freetype/include/freetype/config/ftconfig.h330行

  1. "orr%0,%0,%2,lsl#16\n\t"/*%0|=%2<<16*/  
  2. //原来:"orr%0,%2,lsl#16\n\t" 

2)/src/3rdparty/webkit/WebCore/Makefile

14行和15行,分别在-fPIC$(DEFINES)之前加入-D__ARM_ARCH_4T__(即CFLAGS/CXXFLAGS)

3) /src/script/Makefile

14行和15行-D__ARM_ARCH_4T__(同上)

  1. make&&makeinstall 

二、环境搭建(Trolltech)

1、设置环境变量Qt-4.6.3

进入/usr/local/Trolltech/Qt-4.6.3目录

visetenv.sh或者sudogeditsetenv.sh

在文件中加入

  1. PATH=/usr/local/Trolltech/Qt-4.6.3/bin:$PATH  
  2. LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.6.3/lib:$LD_LIBRARY_PATH 

保存退出

  1. chmod777setenv.sh 

2、设置环境变量Qt-4.6.3-x86

进入/usr/local/Trolltech/Qt-4.6.3-x86目录

visetenv.sh或者sudogeditsetenv.sh

在文件中加入

  1. QTEDIR=/usr/local/Trolltech/Qt-4.6.3-x86  
  2. PATH=/usr/local/Trolltech/Qt-4.6.3-x86/bin:$PATH  
  3. LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.6.3-x86/lib:$LD_LIBRARY_PATH 

保存退出

  1. chmod777setenv.sh 

3、设置环境变量Qt-4.6.3-arm

进入/usr/local/Trolltech/Qt-4.6.3-arm目录

visetenv.sh或者sudogeditsetenv.sh

在文件中加入

  1. QTEDIR=/usr/local/Trolltech/Qt-4.6.3-arm  
  2. PATH=/usr/local/Trolltech/Qt-4.6.3-arm/bin:$PATH  
  3. LD_LIBRARY_PATH=/usr/local/Trolltech/Qt-4.6.3-arm/lib:$LD_LIBRARY_PATH 

保存退出

  1. chmod777setenv.sh 

三、编译qvfb

  1. cdqt-everywhere-opensource-4.6.3-x11/tools/qvfb  
  2. #####/usr/local/qt-everywhere-opensource-src-4.6.3-x11/tools/qvfb  
  3. make 

--会在qt-everywhere-opensource-4.6.3-x11/bin下生成qvfb,

我们将它copy至/usr/local/Trolltech/Qt-4.6.3-x86/bin下

  1. cpqvfb/usr/local/Trolltech/Qt-4.6.3-x86/bin 

运行测试()

运行x86下setenv.sh脚本文件。sourcesetenv.sh(word里大写S不对)命令行输入qvfb&(&后台运行)

对Qtcreator工程文件qmake文件名.pro然后make生成可执行文件

  1. ./可执行文件-qws  
  2. (示例文件可以去qt-everywhere-opensource-4.6.3-x86/examples或者demos里面找) 

四、安装QTCreator

  1. chmod777qt-sdk-linux-x86-opensource_2010.02.bin  
  2. cpqt-sdk-linux-x86-opensource_2010.02.bin/opt  
  3. ./qt-sdk-linux-x86-opensource_2010.02.bin默认安装即可 

六、在ubuntu中安装NFS服务,在开发内核和文件系统时很方便,可以直接采用NFS启动内核和文件系统。安装如下:

1、安装

#apt-getinstallnfs-kernel-server

2、将NFS端口是否打开

  1. #netstat-tl 

若NFS端口处于LISTEN状态,则打开

3、配置NFS服务器

  1. #vim/etc/exports 

在***一行加入:/work*(rw,sync,no_root_squash)其中:/work为共享目录,*为任意IP地址都可以访问,no_root_squash表示任意用户都可以访问

4、重启NFS服务

  1. #/etc/init.d/nfs-kernel-serverrestart 

5、查看NFS服务器当前的工作状态

#/etc/init.d/nfs-kernel-serverstatus

若显示running则工作正常

安装结束

#p#

五、ARM板上配置环境:(板子和电脑之间)

编辑目标环境下(/utulinux2.6.24/s3c2440_recover/etc)的/etc/profile,在文件后面添加如下内容:(和ppt上的有少许区别,主要是路径上)

  1. exportLD_LIBRARY_PATH=/lib:$LD_LIBRARY_PATH  
  2. exportQTDIR=/usr/local/Trolltech/Qt-4.6.3-arm  
  3. exportQPEDIR=$QTDIR  
  4. exportT_ROOT=/opt/ts  
  5. exportPATH=$T_ROOT/bin:$PATH  
  6. exportLD_LIBRARY_PATH=$T_ROOT/lib:$QTDIR/lib:$LD_LIBRARY_PATH  
  7. exportTSLIB_CONSOLEDEVICE=none 
  8. exportTSLIB_FBDEVICE=/dev/fb0  
  9. exportTSLIB_TSDEVICE=/dev/event0  
  10. exportTSLIB_PLUGINDIR=$T_ROOT/lib/ts  
  11. exportTSLIB_CONFFILE=$T_ROOT/etc/ts.conf  
  12. exportTSLIB_CALIBFILE=/etc/pointercal  
  13. exportQWS_KEYBOARD=USB:/dev/input/event1  
  14. exportQWS_MOUSE_PROTO=Tslib:/dev/event0  
  15. exportQWS_DISPLAY=LinuxFb:mmWidth45:mmHeight60:0  
  16. exportQWS_SIZE=320x240 

六.在目标环境中建立与编译QT-arm一样的路径:(目标路径/utulinux2.6.24/s3c2440_recover)

  1. mkdir/usr/local/Trolltech/Qt-4.6.3-arm  
  2. cd/usr/local/Trolltech/Qt-4.6.3-arm  
  3. mkdirlib/  
  4. mkdirlib/fonts/ 

把以下的库文件从编译主机中的lib复制目录中的四个库文件复制到目标板的/usr/local/Qt-4.6.3-arm/lib

  1. libQtCore.so.4.6.3  
  2. libQtGui.so.4.6.3  
  3. libQtNetwork.so.4.6.3  
  4. libQtSql.so.4.6.3 

为每个库文件创建3个连接:*.so,*.so.4,*.so.4.6

  1. ln–slibQtCore.so.4.6.3libQtCore.so  
  2. ln–slibQtCore.so.4.6.3libQtCore.so.4  
  3. ln–slibQtCore.so.4.6.3libQtCore.so.4.6 

(重复其余三个)

常用字库文件从/usr/local/Trolltech/Qt-4.6.3-arm/lib/fonts/复制到目标板的

  1. /utulinux2.6.24/s3c2440_recover/usr/local/Trolltech/Qt-4.6.3-arm/lib/fonts  
  2. cp-rf/usr/local/Trolltech/Qt-4.6.3-arm/lib/fonts/\/utulinux2.6.24/s3c2440_recover/usr/local/Trolltech/Qt-4.6.3-arm/lib 

七、

1:将/opt下交叉编译好的tslib文件cp到开发板中对应的同样目录下,其中的include目录和lib下的pkgconfig目录可以不拷贝。

进入到/opt复制ts目录

cp-rfts/utulinux2.6.24/s3c2440_recover/opt/

2:检查/utulinux2.6.24/s3c2440_recover/opt/

ts/etc/ts.conf内容加入module_rawinput:

module_rawinput(必须顶格,不然bug)

  1. modulepthrespmin=1 
  2. modulevariancedelta=30 
  3. moduledejitterdelta=100 
  4. modulelinear 

八.cd/usr/local/Trolltech/Qt-4.6.3-arm/mkspecs/default

//这个问题找了好久,结果发现是这里目录错了,应该是

cd/usr/local/Trolltech/Qt-4.6.3-arm/mkspecs/qws/linux-arm-g++

不然后面qmake时会出错

修改qmake配置文件:

viqmake.conf打开文件中在QMAKE_LINK_SHLIB此行下面加入一行:

QMAKE_LFLAGS+=-Wl-lts加入后如下:

  1. #modificationstog++.conf  
  2. QMAKE_CC=arm-linux-gcc  
  3. QMAKE_CXX=arm-linux-g++  
  4. QMAKE_LINK=arm-linux-g++  
  5. QMAKE_LINK_SHLIB=arm-linux-g++  
  6. QMAKE_LFLAGS+=-Wl-lts  
  7. #modificationstolinux.conf  
  8. QMAKE_AR=arm-linux-arcqs  
  9. QMAKE_OBJCOPY=arm-linux-objcopy  
  10. QMAKE_STRIP=arm-linux-strip  
  11. load(qt_config) 

九.将例子hellowrld拷贝到/utulinux2.6.24/s3c2440_recover/usr下测试

在串口终端进入文件夹中./helloworld-qws

//这里讲得不清楚,是这样的,因为要在arm板上运行,所以要用Qt-4.6.3-arm中对应的qmake编译

先要执行该文件中的setenv.sh

  1. source/usr/local/Trolltech/Qt-4.6.3-arm/setenv.sh 

执行后环境变量就在本终端中有效,不要切换终端qmake

然后找到要编译的项目qmakename.pro

  1. make 

生成和项目名一样的可执行文件,该文件可以在arm板上执行

CRT中输入./name-qws即可

十.错误解决方法:

提示:.

  1. /helloworld:errorwhileloadingsharedlibraries:libts-0.0.so.0:cannotopen  
  2. sharedobjectfile:Nosuchfileordirectory 

Ts触摸屏驱动有问题,解决方法看路径是否对。

//这里说的路径主要是说/utulinux2.6.24/s3c2440_recover/etc/profile中T_ROOT=/opt/ts设置是否正确

错误:

  1. ./helloworld:errorwhileloadingsharedlibraries:libstdc++.so.6:cannotopen  
  2. sharedobjectfile:Nosuchfileordirectory 

对应文件拷贝链接:

进入目标系统lib目录下://这种类似的报错可以到ubuntu中把Qt-4.6.3-arm/lib下的文件拷贝过来,软连接的话自己建

  1. ln-slibstdc++.so.60.0.3libstdc++.so.6 

错误:

  1. CannotcreateQtforEmbeddedLinuxdatadirectory:/tmp/qtembedded-0Aborted 

在目标板根目录下创建文件夹:

mkdirtmp

十一.重启nfs服务://这里不一定需要

  1. /etc/init.d/nfs-kernel-serverrestart 

重启板子reboot

校准:(遇到错误提示如下)

  1. Couldnotreadcalibration:"/etc/pointercal" 

超级终端命令行输入:ts_calibrate运行

在触摸屏上点击鼠标跟踪。

重新再运行helloworld

十二、想要板子开机运行程序要挂载电脑端的utulinux目录

首先启动utubootloader运行:setenvbootargs

saveenv启动后运行:

  1. mount-tnfs192.168.1.200:/utulinux2.6.24/s3c2440_recover/media/nfs 

(挂载不了重启板子reboot)

小结:详解QT安装全过程的内容介绍完了,希望通过本文的QT安装的内容学习能对你有所帮助!

责任编辑:zhaolei 来源: 互联网
相关推荐

2010-03-10 13:24:45

Zend Debugg

2011-02-22 10:46:02

Samba配置

2011-01-21 17:51:52

2011-06-24 13:08:34

Qt Qt 4.5.3 移植

2009-06-10 16:55:42

cygwin netb安装

2011-03-11 10:39:02

YUM安装LAMP

2009-11-02 14:53:30

Oracle创建用户权

2010-11-19 09:30:29

2010-03-26 14:48:03

Ylmf OS 2.0

2010-03-30 10:11:53

CentOS源

2011-04-02 09:20:23

freebsdmrtg安装

2015-06-08 09:43:18

青云QingCloudIDC

2015-07-08 09:57:59

Git服务器分步详解

2009-12-08 17:56:16

WCF配置

2011-04-18 15:56:10

软件测试

2009-04-23 10:04:55

2009-04-13 12:37:18

2009-10-21 09:14:26

Visual Stud

2009-03-04 10:10:49

PVS服务器桌面虚拟化Xendesktop

2010-03-01 17:01:03

Python编程技巧
点赞
收藏

51CTO技术栈公众号