厦门手机网站建设,装饰网站模板下载,南宁建设信息网,网站设计模板怎么使用本文转自#xff1a;http://blog.chinaunix.net/uid-7945126-id-4987195.html 经测试完美解决 ------------------------------------------------------------- 最近需要在Ubuntu下开发桌面软件#xff0c;想起了QT。书上介绍的方法太老了#xff0c;网上找了一大堆安装方法… 本文转自http://blog.chinaunix.net/uid-7945126-id-4987195.html 经测试完美解决 ------------------------------------------------------------- 最近需要在Ubuntu下开发桌面软件想起了QT。书上介绍的方法太老了网上找了一大堆安装方法都或多或少有各种问题以下是我自己摸索出来的与大家分享另外不建议大家现在用QT5参考资料不多建议初学者先从QT4学起。本文写作时间是2013年11月份。 本文使用的环境 QT Library 4.8.1http://download.qt-project.org/archive/qt/4.8/4.8.1/qt-everywhere-opensource-src-4.8.1.tar.gz QT Creator2.4.1http://download.qt-project.org/archive/qtcreator/2.4/qt-creator-linux-x86-opensource-2.4.1.bin Ubuntu10.04.4http://old-releases.ubuntu.com/releases/10.04.0/ubuntu-10.04.4-desktop-i386.iso 安装QT分为两步第一步是QT Library的安装第二步是QT Creator的安装QT Creator是QT的集成开发环境。 第一步 安装QT Library 1、诺基亚把QT卖给Digia后QT商业版和开源版就分开了开源版全部放在QT Project网站上从该网站下载qt-everywhere-opensource-src-4.8.1.tar.gz。可以在Ubuntu里面使用Firefox浏览器下载默认下载目录是/home/your name/Downloads使用终端cd到Downloads目录然后使用命令 [plain] view plaincopy print? tar xzvf qt-everywhere-opensource-src-4.8.1.tar.gz 解压软件包解压完后cd到该目录[plain] view plaincopy print? cd qt-everywhere-opensource-src-4.8.1 2、我的电脑在Ubuntu 10.04.4环境下没有安装g编译QT要用到g所以首先安装g使用apt-get命令安装g [plain] view plaincopy print? sudo apt-get install g 3、
然后需要安装libX11-dev libXext-dev libXtst-dev这三个包这点非常重要很多朋友因为没有安装这三个包而出现以下错误[plain] view plaincopy print? 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/your name/Qt/qt-x11-opensource-src-4.8.1/mkspecs/linux-g 使用apt-get安装这三个包[plain] view plaincopy print? sudo apt-get install libX11-dev libXext-dev libXtst-dev 4、
如果你的Ubuntu已经安装g和libX11-dev libXext-dev libXtst-dev可以跳过23两步。在进入qt-everywhere-opensource-src-4.8.1目录后使用如下命令配置QT Library[plain] view plaincopy print? ./configure 注意不能直接输入configure必须加上 ./ 才可以。然后终端会出现让你选择商业版还是开源版输入字母o选择开源版。然后会有协议让你接受输入yes就OK啦。5、经过漫长地等待后终端会出现如下信息 [plain] view plaincopy print? 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.1 To reconfigure ,run make confclean and configure 然后输入make这样会生成QT库同时编译所有演示程序。[plain] view plaincopy print? make 6、
QT编译完成后输入make install来安装QT注意make install需要root权限所以要加sudo。[plain] view plaincopy print? sudo make install 7、
经过漫长等待QT安装完毕后首先进入QT安装目录测试QT是否安装成功QT默认安装在/usr/local/Trolltech/Qt-4.8.1目录里面所以先进入该目录[plain] view plaincopy print? cd /usr/local/Trolltech/Qt-4.8.1 然后在进入qmake所在的bin文件夹[plain] view plaincopy print? cd bin 然后输入qmake如果出现正常的信息则表明QT已经安装成功。或者输入以下指令[plain] view plaincopy print? qmake -v 如果出现正确的版本信息则表示安装成功了。8、接下来要设置环境变量设置环境变量的目的是为了在任何目录下都可以使用QT。首先需要设置用户环境变量 [plain] view plaincopy print? gedit /home/your name/.bashrc 然后会弹出一个编辑窗口在末尾添加以下代码[plain] view plaincopy print? export QTDIR/usr/local/Trolltech/Qt-4.8.1 export PATH$QTDIR/bin:$PATH export MANPATH$QTDIR/man:$MANPATH export LD_LIBRARY_PATH$QTDIR/lib:$LD_LIBRARY_PATH 然后设置root用户的环境变量设置root用户的环境变量需要root权限所以要加sudo[plain] view plaincopy print? sudo gedit /etc/profile 然后会弹出一个编辑窗口在末尾添加以下代码[plain] view plaincopy print? export QTDIR/usr/local/Trolltech/Qt-4.8.1 export PATH$QTDIR/bin:$PATH export MANPATH$QTDIR/man:$MANPATH export LD_LIBRARY_PATH$QTDIR/lib:$LD_LIBRARY_PATH 保存后退出然后重启电脑。 9、重启电脑后打开终端在任意目录下输入qmake如果能出现正确信息则表明环境变量已经配置成功。 第二步 安装QT Creator 相比QT LibraryQT Creator的安装要简单的多我们下载的bin文件是可执行文件安装时会出现像在Windows下的界面安装路径默认就可以了。使用终端cd到Downloads目录首先修改bin文件的权限使其具有可执行的权限 [plain] view plaincopy print? chmod ax qt-creator-linux-x86-opensource-2.4.1.bin 然后输入以下命令安装bin文件[plain] view plaincopy print? ./qt-creator-linux-x86-opensource-2.4.1.bin 至此QT已经安装完毕打开桌面上的QT Creator来运行一个demo测试吧