Qt4.8.5 x86开发环境搭建【完整流程】
环境:workstations VM11、Ubuntu
Qt4.8.5 开发环境搭建【完整流程】关于编译出现的问题,我另开一贴再次解决。
1.首先在 ubuntu10.04 系统的/home/ye 目录中,创建一个 Qt 文件夹,复制文件qt-everywhere-opensource-src-4.8.5.tar.gz 到 Qt 文件夹中,并且解压:
1$ tar –zxvf qt-everywhere-opensource-src-4.8.5.tar.gz
2. 编译 qt 需要 g++,在终端输入 g++ -v,如果出现如下图所示,说明已经安装了 g++,否则执行命令来
安装 g++:
1$ sudo apt-get install g++
安装成功:
1234567yechuang@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, 出现如下图所
示,选择开源版本
1234567891011121314151617181920212223yechuang@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.
<strong><font color=
"#ff0000"
>o</font></strong>
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?<font color=
"#ff0000"
> </font><strong><font color=
"#ff0000"
>yes</font>
</strong>……………………
1
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 开发环境搭建【编译出现的问题】
1yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ ls
bin 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
1 | 这个过程时间有点长,耐心等待。 |
1 | 5.完成编译后安装 |
1yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ sudo make install
1 | |
1 | 6.完成安装后查看系统中的/usr/local/Trolltech 里面安装了编译的 Qt4.8.5 |
12yechuang@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;
1yechuang@yechuang:~/Qt/qt-everywhere-opensource-src-4.8.5$ sudo vi /etc/profile
1
12345678910111213141516171819202122232425262728# /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
<strong><font color=
"#ff0000"
>export PATH=/usr/local/Trolltech/Qt-4.8.5/bin:$PATH</font></strong>
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问题1:出现无法更改环境变量情况,在<a href=
"http://www.cnblogs.com/yechuang/p/4511348.html"
target=
"_blank"
>http://www.cnblogs.com/yechuang/p/4511348.html</a>中查看解决办法。
1 | 8. Qt4.8.5 编译、安装和配置完成 |
1 | <blockquote><pre class = "brush: cpp; auto-links: true; collapse: false; first-line: 1; gutter: html-script: light: ruler: smart-tabs: tab-size: 4; toolbar:" >$ sudo qmake –v</pre></blockquote> |
1 | <blockquote><pre class = "brush: cpp; auto-links: true; collapse: false; first-line: 1; gutter: html-script: light: ruler: smart-tabs: tab-size: 4; toolbar:" >QMake version 2.01aUsing Qt version 4.8.5 in /usr/local/Trolltech/Qt-4.8.5 /lib</pre><pre class = "brush: cpp; auto-links: true; collapse: false; first-line: 1; gutter: html-script: light: ruler: smart-tabs: tab-size: 4; toolbar:" > </pre></blockquote> |
1 | 问题2: |
qmake: could not exec '/usr/lib/i386-linux-gnu/qt4/bin/qmake': No such file or directory
1 | 找不到qmake的解决办法<a href= "http://www.cnblogs.com/yechuang/p/4511348.html" >http://www.cnblogs.com/yechuang/p/4511348.html</a> |
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步