ubuntu12.10安装QT
1.下载安装文件qt-everywhere-opensource-src-4.7.4.tar.gz2.解压tar-xzvfqt-everywhere-opensource-src-4.7.4.tar.gz3.更改目录权限chmod 777 qt-everywhere-opensource-src-4.7.4cd qt-everywhere-opensource-src-4.7.44.执行配置文件命令./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/profileexport 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 -vroot@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
[*]#include <QApplication>
#include <QPushButton>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QPushButton hello("Hello world!");
hello.resize(100, 30);
hello.show();
return app.exec();
}
在qthello.cpp目录下依次执行如下命令
[*]root@ubuntu:~/test/qttest# ls
qthello.cppqttest.pro
root@ubuntu:~/test/qttest# rm -rf qttest.pro
root@ubuntu:~/test/qttest# ls
qthello.cpp
root@ubuntu:~/test/qttest# qmake -project
root@ubuntu:~/test/qttest# ls
qthello.cppqttest.pro
root@ubuntu:~/test/qttest# qmake qttest.pro
root@ubuntu:~/test/qttest# ls
Makefileqthello.cppqttest.pro
root@ubuntu:~/test/qttest# make
g++ -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.cpp
g++ -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# ls
Makefileqthello.cppqthello.oqttestqttest.pro
root@ubuntu:~/test/qttest# ls
Makefileqthello.cppqthello.oqttestqttest.pro
root@ubuntu:~/test/qttest# ./qttest
窗口出现一个对话框,里面内容为hello world!
生我之前谁是我,生我之后我是谁? 漏洞与补丁齐飞,蓝屏共死机一色! 为中华而努力读书!一包中华好多钱啊~~~ 花前月下,不如花钱“日”下!*^_^* 我不在江湖,但江湖中有我的传说。 男人与女人,终究也只是欲望的动物吧!真的可以因为爱而结合吗?对不起,我也不知道。。
页:
[1]