环境:workstations VM11、Ubuntu
Qt4.8.5 开发环境搭建【完整流程】关于编译出现的问题,我另开一贴再次解决。
1.首先在 ubuntu10.04 系统的/home/ye 目录中,创建一个 Qt 文件夹,复制文件qt-everywhere-opensource-src-4.8.5.tar.gz 到 Qt 文件夹中,并且解压:
$ tar –zxvf qt-everywhere-opensource-src-4.8.5.tar.gz
2. 编译 qt 需要 g++,在终端输入 g++ -v,如果出现如下图所示,说明已经安装了 g++,否则执行命令来
安装 g++:
$ sudo apt-get install g++
安装成功:
yechuang@yechuang:~/Qt$ g++ -v Using built-in specs. Target: i486-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5.1' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc --enable-targets=all --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=i486-linux-gnu --host=i486-linux-gnu --target=i486-linux-gnu Thread model: posix gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5.1) yechuang@yechuang:~/Qt$
再安装所需的三个包:
yechuang@yechuang:~/Qt$ sudo apt-get install libX11-dev libXext-dev libXtst-dev
$ sudo apt-get install libX11-dev libXext-dev libXtst-dev
…………现象
正在设置 x11proto-xext-dev (7.1.1-2) ... 正在设置 libxext-dev (2:1.1.1-2ubuntu0.1) ... 正在设置 libxi6 (2:1.3-3ubuntu0.2) ... 正在设置 libxi-dev (2:1.3-3ubuntu0.2) ... 正在设置 libxtst6 (2:1.1.0-2ubuntu0.1) ... 正在设置 x11proto-record-dev (1.14-2) ... 正在设置 libxtst-dev (2:1.1.0-2ubuntu0.1) ... 正在处理用于 libc-bin 的触发器... ldconfig deferred processing now taking place
安装成功 。
3. 进入刚刚解压的 qt 源码目录中:cd qt-everywhere-opensource-src-4.8.5/; 执行./configure, 出现如下图所
示,选择开源版本
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ ./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'.
4.编译源码,执行make
如果安装成功,则生成makefile ,如果没有正常生成请看 另一帖:Qt4.8.5 开发环境搭建【编译出现的问题】
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ lsbin configure.exe INSTALL Makefile srcchanges-4.8.5 demos LGPL_EXCEPTION.txt mkspecs templates config.profiles doc lib plugins tools config.status examples LICENSE.FDL projects.pro translations config.tests imports LICENSE.GPL3 qmake util configure include LICENSE.LGPL README
在这里就看出了已经生成了makefile了,执行
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ make
这个过程时间有点长,耐心等待。
5.完成编译后安装
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ sudo make install
6.完成安装后查看系统中的/usr/local/Trolltech 里面安装了编译的 Qt4.8.5
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ ls /usr/local/Trolltech/ Qt-4.8.5
7.配置环境变量, $ sudo vim /etc/profile, 将/usr/local/Trolltech/Qt-4.8.5/bin 加入环境变量,然后 生效环境
变量$ source /etc/profile;
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ sudo vi /etc/profile# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) # and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). if [ -d /etc/profile.d ]; then for i in /etc/profile.d/*.sh; do if [ -r $i ]; then . $i fi done unset i fi export PATH=/usr/local/Trolltech/Qt-4.8.5/bin:$PATH if [ "$PS1" ]; then if [ "$BASH" ]; then PS1='u@h:w$ ' if [ -f /etc/bash.bashrc ]; then . /etc/bash.bashrc fi else if [ "`id -u`" -eq 0 ]; then PS1='# ' else PS1='$ ' fi fi fi umask 022问题1:出现无法更改环境变量情况,在http://www.cnblogs.com/yechuang/p/4511348.html中查看解决办法。
8. Qt4.8.5 编译、安装和配置完成
$ sudo qmake –v
QMake version 2.01aUsing Qt version 4.8.5 in /usr/local/Trolltech/Qt-4.8.5 /lib
问题2:
qmake: could not exec '/usr/lib/i386-linux-gnu/qt4/bin/qmake': No such file or directory
找不到qmake的解决办法http://www.cnblogs.com/yechuang/p/4511348.html