Qt4.8.不同于Qt5.。首先没有自带的QtCreator,需要自己安装。下面是Qt4.8.5+QtCreator2.6.0的安装。
1.安装前准备
安装前需要下载Qt4.8.6和QtCreator2.6.1
Qt4.8.5:http://download.qt.io/archive/qt/4.8/4.8.5/
QtCreator2.6.1:http://download.qt.io/archive/qtcreator/2.6/2.6.1/

- 安装QtCreator
将下载的两个包放在一个目录下:

打开终端(Ctrl+Alt+T)进入命令行:先对文件赋权,在执行命令。
chmod +777 qt-creator-linux-x86_64-opensource-2.6.1.bin
`./qt-creator-linux-x86_64-opensource-2.6.1.bin`
然后进入QtCreator安装界面,指定安装位置, 然后就是按照提示一直到安装结束。

- 安装Qt4.8.5
(1)首先解压缩该包:
tar -xzvf qt-everywhere-opensource-src-4.8.5.tar.gz
(2)然后进入文件夹:cd ./qt-everywhere-opensource-src-4.8.5/
(3)对软件进行配置并检查环境依赖关系是否满足:
若不满足:先执行sudo apt-get install libx11-dev libxext-dev libxtst-dev
$ ./configure
如下:
Which edition of Qt do you want to use ?
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.
o
This is the Open Source Edition.
You are licensed to use this software under the terms of
the Lesser GNU General Public License (LGPL) versions 2.1.
You are also licensed to use this software under the terms of
the GNU General Public License (GPL) versions 3.
Type '3' to view the GNU General Public License version 3.
Type 'L' to view the Lesser GNU General Public License version 2.1.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.
Do you accept the terms of either license? yes
……
Qt is now configured for building. Just run 'make'.
Once everything is built, you must run 'make install'.
Qt will be installed into /usr/local/Trolltech/Qt-4.8.5
To reconfigure, run 'make confclean' and 'configure'.
若./configure报错:
Basic XLib functionality test failed!
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_X11 and QMAKE_LIBDIR_X11 in /home/qt-everywhere-opensource-src-4.7.3/mkspecs/linux-g++.
解决办法:
按顺序安装依赖库:
yum install libXau-devel
yum install ibX11-devel
yum install libXext-devel
(4)然后进行编译:
make
编译时间比较长,请耐心等待。
编译报错:
make[1]: *** [Makefile:1610: obj/release/pcre_exec.o] Error 1
make[1]: Leaving directory '/home/hanyf/software/Qt4.8.5/qt-everywhere-opensource-src-4.8.5/src/script'
make: *** [Makefile:602: sub-script-make_default-ordered] Error 2
解决方案:
(5)编译完成,进行安装
sudo make install
sudo用来获取
管理者权限
(6)环境变量配置
vi ~/.bash_profile
然后在.bash_profile文件末尾添加下面几行
export QTDIR=/usr/local/Trolltech/Qt-4.8.6
export PATH=
Q
T
D
I
R
/
b
i
n
:
QTDIR/bin:
QTDIR/bin:PATH
export MANPATH=
Q
T
D
I
R
/
m
a
n
:
QTDIR/man:
QTDIR/man:MANPAT
export LD_LIBRARY_PATH=
Q
T
D
I
R
/
l
i
b
:
QTDIR/lib:
QTDIR/lib:LD_LIBRARY_PATH
如果要让该配置立刻生效,需要执行下面命令,或者注销当前用户,重新登录也行。
$:source ~/.bash_profile
测试:
qmake -v
报错:qmake命令无法找到
QT安装后,/usr/local/Trolltech/Qt-4.8.5/bin目录下已经存在qmake,需要将路径添加到环境变量中,(6)中已经添加,可通过cat $PATH,检查是否成功添加,若没有,重新添加。
下图是添加后,打印的PATH全部路径。


1099

被折叠的 条评论
为什么被折叠?



