主机版本:ubuntu11.04
编译器版本:gcc 4.5.2
准备工作,下载源码包
http://qt.nokia.com/downloads/downloads#qt-creator
这里有几个不同的版本,我们下载的是 Qt libraries 4.8.2 for Linux/X11,也就是QT/X11。
1、建立工作目录
root@rjm-home:~#mkdir work
root@rjm-home:~# ls
work 公共的 模板 视频 图片 文档 下载 音乐 桌面
root@rjm-home:~# cd work/
root@rjm-home:~/work# mkdir Qt
root@rjm-home:~/work# ls
Qt
1、建立工作目录 root@rjm-home:~#mkdir work root@rjm-home:~# ls work 公共的 模板 视频 图片 文档 下载 音乐 桌面 root@rjm-home:~# cd work/ root@rjm-home:~/work# mkdir Qt root@rjm-home:~/work# ls Qt2、把下载好的源文件(我这里包括了Creator),复制到工作目录
root@rjm-home:~/work#cd Qt
root@rjm-home:~/work/Qt# ls
qt-creator-linux-x86-opensource-2.5.0.bin
qt-everywhere-opensource-src-4.8.2.tar.gz
2、把下载好的源文件(我这里包括了Creator),复制到工作目录 root@rjm-home:~/work#cd Qt root@rjm-home:~/work/Qt# ls qt-creator-linux-x86-opensource-2.5.0.bin qt-everywhere-opensource-src-4.8.2.tar.gz3、解压,因为是tar.gz格式的,所以先有gunzip解压成tar格式的文件,再用tar解压
root@rjm-home:~/work/Qt# gunzip qt-everywhere-opensource-src-4.8.2.tar.gz
root@rjm-home:~/work/Qt# ls
qt-creator-linux-x86-opensource-2.5.0.bin
qt-everywhere-opensource-src-4.8.2.tar
root@rjm-home:~/work/Qt#tar xvf qt-everywhere-opensource-src-4.8.2.tar.gz
解压完成后
root@rjm-home:~/work/Qt# ls
qt-creator-linux-x86-opensource-2.5.0.bin
qt-everywhere-opensource-src-4.8.2
qt-everywhere-opensource-src-4.8.2.tar
3、解压,因为是tar.gz格式的,所以先有gunzip解压成tar格式的文件,再用tar解压 root@rjm-home:~/work/Qt# gunzip qt-everywhere-opensource-src-4.8.2.tar.gz root@rjm-home:~/work/Qt# ls qt-creator-linux-x86-opensource-2.5.0.bin qt-everywhere-opensource-src-4.8.2.tar root@rjm-home:~/work/Qt#tar xvf qt-everywhere-opensource-src-4.8.2.tar.gz 解压完成后 root@rjm-home:~/work/Qt# ls qt-creator-linux-x86-opensource-2.5.0.bin qt-everywhere-opensource-src-4.8.2 qt-everywhere-opensource-src-4.8.2.tar解压完成后,进入源码目录进行配置。
4、配置
root@rjm-home:~/work/Qt/qt-everywhere-opensource-src-4.8.2#./configure -prefix /usr/local/Qt-4.8.2
(上面指定的这个目录“/usr/local/Qt-4.8.2”,就是make install后的安装目录)
(经过一小会儿,配置完成,会出现以下信息)
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/Qt-4.8.2
To reconfigure, run 'make confclean' and 'configure'.
4、配置 root@rjm-home:~/work/Qt/qt-everywhere-opensource-src-4.8.2#./configure -prefix /usr/local/Qt-4.8.2 (上面指定的这个目录“/usr/local/Qt-4.8.2”,就是make install后的安装目录) (经过一小会儿,配置完成,会出现以下信息) 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/Qt-4.8.2 To reconfigure, run 'make confclean' and 'configure'.root@rjm-home:~/work/Qt/qt-everywhere-opensource-src-4.8.2#make
(经过N久)
root@rjm-home:~/work/Qt/qt-everywhere-opensource-src-4.8.2#make install
(经过make install qt已经被安装在了/usr/local/Qt-4.8.2/这个文件夹中)
5、编译 root@rjm-home:~/work/Qt/qt-everywhere-opensource-src-4.8.2#make (经过N久) root@rjm-home:~/work/Qt/qt-everywhere-opensource-src-4.8.2#make install (经过make install qt已经被安装在了/usr/local/Qt-4.8.2/这个文件夹中)
6、设置环境变量
可以在home/用户/.profile中增加 (用户就是你当前登录的用户)
QTDIR=/usr/local/Qt-4.8.2
PATH=$QTDIR/bin:$PATH
MANPATH=$QTDIR/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QTDIR PATH MANPATH LD_LIBRARY_PATH
6、设置环境变量 可以在home/用户/.profile中增加 (用户就是你当前登录的用户) QTDIR=/usr/local/Qt-4.8.2 PATH=$QTDIR/bin:$PATH MANPATH=$QTDIR/man:$MANPATH LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH export QTDIR PATH MANPATH LD_LIBRARY_PATH
哦了,经过上面的操作,已经编译安装完成,并且已经设置好了环境变量。在终端中输入qmake,如果出现很多提示信息而不是connotfind,就说明成功了。