首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

ubuntu12.10装配QT

2013-03-28 
ubuntu12.10安装QT1.下载安装文件qt-everywhere-opensource-src-4.7.4.tar.gz2.解压tar-xzvfqt-everywhere

ubuntu12.10安装QT

1.下载安装文件

qt-everywhere-opensource-src-4.7.4.tar.gz

2.解压

tar  -xzvf  qt-everywhere-opensource-src-4.7.4.tar.gz

3.更改目录权限

chmod 777 qt-everywhere-opensource-src-4.7.4

cd qt-everywhere-opensource-src-4.7.4

4.执行配置文件命令
    ./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',即自由版本。然后输出以下内容:

    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?

    上面大概意思就是说:
    这是Linux/X11 Qt的开源版本,GNU通用公共许可证(LGPL),版本2.1和版本3,允许你使用该软件,
按'3'来查看版本3,按'L'来查看版本2.1,按“yes”接受此许可提供;按“no”不接受此许可提供。
我按了“yes”
然后就是:
    Creating qmake. Please wait...
    ....................
    ....................
  
    等一会配置完成,输出如下:
    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.7.4

    To reconfigure, run 'make confclean' and 'configure'.

5.安装

make

大概需要2小时

完成后执行make install.
make install
由于默认安装至 /usr/local/Trolltech/Qt-4.7.4

运行 /usr/local/Trolltech/Qt-4.8.1/bin/designer
 cd  /usr/local/Trolltech/Qt-4.7.4/bin
  ./designer
 看见qt启动,也就是说qt安装好了。

6.添加环境变量

# vim /etc/profile

export QTDIR=/usr/local/Trolltech/Qt-4.7.4
export PATH=$QTDIR/bin:$PATH
export MANPATH=$QTDIR/man:$MANPATH
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
测试一下重新打开一个终端

qmake -v

root@ubuntu:~/Downloads# qmake -v
QMake version 2.01a
Using Qt version 4.7.4 in /usr/local/Trolltech/Qt-4.7.4/lib
root@ubuntu:~/Downloads#
说明安装成功

7.编辑一个QT程序测试一下

qthello.cpp

root@ubuntu:~/test/qttest# lsqthello.cpp  qttest.proroot@ubuntu:~/test/qttest# rm -rf qttest.pro root@ubuntu:~/test/qttest# lsqthello.cpproot@ubuntu:~/test/qttest# qmake -projectroot@ubuntu:~/test/qttest# lsqthello.cpp  qttest.proroot@ubuntu:~/test/qttest# qmake qttest.pro root@ubuntu:~/test/qttest# lsMakefile  qthello.cpp  qttest.proroot@ubuntu:~/test/qttest# makeg++ -c -m64 -pipe -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/local/Trolltech/Qt-4.7.4/mkspecs/linux-g++-64 -I. -I/usr/local/Trolltech/Qt-4.7.4/include/QtCore -I/usr/local/Trolltech/Qt-4.7.4/include/QtGui -I/usr/local/Trolltech/Qt-4.7.4/include -I. -I. -o qthello.o qthello.cppg++ -m64 -Wl,-O1 -Wl,-rpath,/usr/local/Trolltech/Qt-4.7.4/lib -o qttest qthello.o    -L/usr/local/Trolltech/Qt-4.7.4/lib -lQtGui -L/usr/local/Trolltech/Qt-4.7.4/lib -L/usr/X11R6/lib64 -lQtCore -lpthread root@ubuntu:~/test/qttest# lsMakefile  qthello.cpp  qthello.o  qttest  qttest.proroot@ubuntu:~/test/qttest# lsMakefile  qthello.cpp  qthello.o  qttest  qttest.proroot@ubuntu:~/test/qttest# ./qttest 窗口出现一个对话框,里面内容为hello world!

热点排行