我的系统为Oracle Linux 6.2(兼容 RHEL 6.2)
到qt.nokia.com下载最新版的 QtSdk-offline-linux-x86-v1.2.1.run
#chmod x+u QtSdk-offline-linux-x86-v1.2.1.run
#./QtSdk-offline-linux-x86-v1.2.1.run
一切都按默认安装,安装好后进行环境变量修改,改/etc下的profile或者bashrc都可以,用vi编辑器打开,
#vi /etc/profile
(注:我的是修改的profile,你也可以修改bashrc或者自己建一个sh文件)
然后在末尾添加以下内容:
QTDIR=/opt/QtSDK/Desktop/Qt/4.8.1/gcc
PATH=$QTDIR/bin:$PATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QTDIR PATH LD_LIBRARY_PATH
然后,ESC 冒号 wq 退出vi编辑器
最后#source /etc/profile
让环境变量立即生效
可以通过以下命令查看是否生效
#qmake -v
我的输出结果为:
QMake version 2.01a
Using Qt version 4.8.1 in /opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib
说明安装成功了!
-------------------------------------------------------割呀割呀割包皮。。。--------------------------------------------------------------------
安装成功后,在做开发的时候,发现还是有错误:vis_shapes.cpp 错误 phonon/... 没有那个文件或目录
查资料发现是phonon的问题,后来一直在折腾也没弄好(包括phonon的问题,这个后面有讲),于是改主意从编译源代码开始弄
之前下过qt-everywhere-opensource-src-4.8.2.zip,注意是“zip”,这是windows下压缩的东东,也就是说里面的文件格式是windows格式的,在linux下出现了不少:
/bin/sh^M:bad interpreter:没有那个文件或目录
于是用vi一个个转码:进入vi后,“:set ff?”查看是否有“dos“或”unix”字样,然后输入“:set ff=unix” 并保存退出,但是目录下大量的文件是windows格式,一个个转会累死的!!
于是直接到网上下载tar.gz格式的压缩包,果然再没了格式问题,但是其他问题接踵而至:
./configure 后提示
"Project ERROR: Package gstreamer-app-0.10 not found."
但我记得我的gstremer是装了的呀!不信,于是查询安装包
# rpm -qa|grep gstreamer
gstreamer-tools-0.10.29-1.0.1.el6.i686
phonon-backend-gstreamer-4.6.2-20.el6.i686
gstreamer-devel-0.10.29-1.0.1.el6.i686
gstreamer-plugins-base-0.10.29-1.el6.i686
gstreamer-0.10.29-1.0.1.el6.i686
gstreamer-python-0.10.16-1.1.el6.i686
gstreamer-ffmpeg-0.10.11-1.el6.rf.i686
PackageKit-gstreamer-plugin-0.5.8-20.0.1.el6.i686
gstreamer-plugins-bad-free-0.10.19-2.el6.i686
gstreamer-plugins-good-0.10.23-1.el6.i686
整整10个包啊!!! 于是google之,在国外论坛上找到了答案原文地址,解决方法如下:
yum install 'pkgconfig(gstreamer-app-0.10)'
然后重新configure:
#./configure -release -nomake demos -nomake examples
目前configure好像没提示这个错误了,正在make中。。。。待续
补充:
源码包解开后有个INSTALL文件,里面是各个平台对应的安装说明文档的路径,X11的是:http://qt-project.org/doc/qt-4.8/install-x11.html
进入以后,里面有安装依赖 的链接http://qt-project.org/doc/qt-4.8/requirements-x11.html 英文看的烦躁,直接用中文简述如下:
名称 | Library | 说明 | 配置选项 | 要求最低版本 |
---|---|---|---|---|
XRender | libXrender | X Rendering Extension; used for anti-aliasing | -xrender or auto-detected | 0.9.0 |
Xrandr | libXrandr | X Resize and Rotate Extension | -xrandr or auto-detected | 1.0.2 |
Xcursor | libXcursor | X Cursor Extension | -xcursor or auto-detected | 1.1.4 |
Xfixes | libXfixes | X Fixes Extension | -xfixes or auto-detected | 3.0.0 |
Xinerama | libXinerama | Multi-head support | -xinerama or auto-detected | 1.1.0 |
Fontconfig | libfontconfig | Font customization and configuration | -fontconfig or auto-detected | 2.1 |
FreeType | libfreetype | Font engine | 2.1.3 | |
Xi | libXi | X11 Input Extensions | -xinput or auto-detected | 1.3.0 |
Xt | libXt | Xt Intrinsics | 0.99 | |
Xext | libXext | X Extensions | 6.4.3 | |
X11 | libX11 | X11 Client-Side Library | 6.2.1 | |
SM | libSM | X Session Management | -sm or auto-detected | 6.0.4 |
ICE | libICE | Inter-Client Exchange | -sm or auto-detected | 6.3.5 |
glib | libglib-2.0 | Common event loop handling | -glib or auto-detected | 2.8.3 |
pthread | libpthread | Multithreading | 2.3.5 |
上表中的这些依赖库,大部分直接#yum install libxxx即可,
但是有几个比较特殊:libfontconfig,libfreetype, libglib-2.0和libpthread,
这三个只需要# yum install fontconfg 和 # yum install freetpye 即可,#yum install glib 将包含libpthread,反正我没有找到libpthread或者pthread的单独包
另外,除了lib外,有些包需要有头文件(即xxx-devel),大致有下面这些:
- libfontconfig1-dev
- libfreetype6-dev
- libx11-dev
- libxcursor-dev
- libxext-dev
- libxfixes-dev
- libxft-dev
- libxi-dev
- libxrandr-dev
- libxrender-dev
到此时此刻,它还木有make完,mark一下。。。。。。先提交保存了。。。