您的位置:首页 > 编程语言 > Qt开发

Qt4.8.5 x86开发环境搭建【完整流程】

2015-05-18 10:49 399 查看
环境:workstationsVM11、Ubuntu

Qt4.8.5开发环境搭建【完整流程】关于编译出现的问题,我另开一贴再次解决。

1.首先在ubuntu10.04系统的/home/ye目录中,创建一个Qt文件夹,复制文件qt-everywhere-opensource-src-4.8.5.tar.gz到Qt文件夹中,并且解压:

$tar–zxvfqt-everywhere-opensource-src-4.8.5.tar.gz

2.编译qt需要g++,在终端输入g++-v,如果出现如下图所示,说明已经安装了g++,否则执行命令来
安装g++:

$sudoapt-getinstallg++

安装成功:

yechuang@yechuang:~/Qt$g++-v Usingbuilt-inspecs. Target:i486-linux-gnu Configuredwith:../src/configure-v--with-pkgversion='Ubuntu4.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 Threadmodel:posix gccversion4.4.3(Ubuntu4.4.3-4ubuntu5.1) yechuang@yechuang:~/Qt$


再安装所需的三个包:
yechuang@yechuang:~/Qt$sudoapt-getinstalllibX11-devlibXext-devlibXtst-dev


$sudoapt-getinstalllibX11-devlibXext-devlibXtst-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的触发器...
ldconfigdeferredprocessingnowtakingplace
安装成功。


3.进入刚刚解压的qt源码目录中:cdqt-everywhere-opensource-src-4.8.5/;执行./configure,出现如下图所
示,选择开源版本

yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$./configure WhicheditionofQtdoyouwanttouse? Type'c'ifyouwanttousetheCommercialEdition. Type'o'ifyouwanttousetheOpenSourceEdition. o ThisistheOpenSourceEdition. Youarelicensedtousethissoftwareunderthetermsof theLesserGNUGeneralPublicLicense(LGPL)versions2.1. Youarealsolicensedtousethissoftwareunderthetermsof theGNUGeneralPublicLicense(GPL)versions3. Type'3'toviewtheGNUGeneralPublicLicenseversion3. Type'L'toviewtheLesserGNUGeneralPublicLicenseversion2.1. Type'yes'toacceptthislicenseoffer. Type'no'todeclinethislicenseoffer. Doyouacceptthetermsofeitherlicense?yes ……………………
Qtisnowconfiguredforbuilding.Justrun'make'.
Onceeverythingisbuilt,youmustrun'makeinstall'.
Qtwillbeinstalledinto/usr/local/Trolltech/Qt-4.8.5

Toreconfigure,run'makeconfclean'and'configure'.

4.编译源码,执行make
如果安装成功,则生成makefile,如果没有正常生成请看另一帖:Qt4.8.5开发环境搭建【编译出现的问题】
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ls
[code]binconfigure.exeINSTALLMakefilesrc
changes-4.8.5demosLGPL_EXCEPTION.txtmkspecstemplates
config.profilesdoclibpluginstools
config.statusexamplesLICENSE.FDLprojects.protranslations
config.testsimportsLICENSE.GPL3qmakeutil
configureincludeLICENSE.LGPLREADME[/code]
在这里就看出了已经生成了makefile了,执行
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$make
这个过程时间有点长,耐心等待。5.完成编译后安装
yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$sudomakeinstall6.完成安装后查看系统中的/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.配置环境变量,$sudovim/etc/profile,将/usr/local/Trolltech/Qt-4.8.5/bin加入环境变量,然后生效环境
变量$source/etc/profile;

yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$sudovi/etc/profile

#/etc/profile:system-wide.profilefilefortheBourneshell(sh(1))
#andBournecompatibleshells(bash(1),ksh(1),ash(1),...).

if[-d/etc/profile.d];then
foriin/etc/profile.d/*.sh;do
if[-r$i];then
.$i
fi
done
unseti
fi
exportPATH=/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`"-eq0];then
PS1='#'
else
PS1='$'
fi
fi
fi

umask022
问题1:出现无法更改环境变量情况,在/article/5841784.html中查看解决办法。8.Qt4.8.5编译、安装和配置完成
$sudoqmake–v
QMakeversion2.01aUsingQtversion4.8.5in/usr/local/Trolltech/Qt-4.8.5/lib
问题2:
qmake:couldnotexec'/usr/lib/i386-linux-gnu/qt4/bin/qmake':Nosuchfileordirectory

找不到qmake的解决办法/article/5841784.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: