Centos 6 安装 Qt 5.6.3

Centos 6 Install Qt 5.6.3

Centos 6 安装 Qt 5.6.3

为什么选择Qt 5.6

Qt 5.6是一个比较折中的版本,Qt5的很多新特性都已具备(例如QWebEngine),而太高的版本在Centos 6上需要手动编译GCC、Glibc、Xorg等其他众多关联环境,甚是繁琐。

下载 Qt 5.6.3

Qt5.6的官方下载链接已经被移除,现在只有长期支持版和最近的版本可以从官方下载。

Centos 6 Install Qt 5.6.3

文件参数 参数值
文件名 qt-opensource-linux-x64-5.6.3.run
文件大小 680MB
文件格式 Qt Linux 安装文件
下载方式 百度网盘
下载工具 百度网盘客户端
下载链接 qt-opensource-linux-x64-5.6.3.run
提取码 54xv

安装 Qt 5.6.3

  1. 赋予文件可执行权限

    # chmod 755 qt-opensource-linux-x64-5.6.3.run
  2. 运行文件完成安装

    # ./qt-opensource-linux-x64-5.6.3.run
  3. 添加环境变量

    • 新建 qt5.sh 文件
      # vim /etc/profile.d/qt5.sh
    • 增加如下内容:
      export PATH="/opt/Qt5.6.3/5.6.3/gcc_64/bin:$PATH"
      export PATH="/opt/Qt5.6.3/Tools/QtCreator/bin:$PATH"
    • :wq 保存并退出
    • 使其生效
      # source /etc/profile
    • 查看设置是否生效
      # which qmake
      /opt/Qt5.6.3/5.6.3/gcc_64/bin/qmake

升级 GCC

  1. 为什么需要升级GCC?
    从 Qt 5.6 的官方的支持文档 https://doc.qt.io/archives/qt-5.6/supported-platforms.html 可以看出,Qt 5.6 需要至少 GCC 4.9.1 的支持(不升级的话很多新功能无法使用,某些 Qt Demo 也无法编译通过),我在这里选择安装 GCC8
    Centos 6 Install Qt 5.6.3

  2. 采用 SCL Repo 库安装 GCC8

    # yum -y install centos-release-scl
    # yum -y install devtoolset-8-gcc devtoolset-8-gcc-c++ devtoolset-8-binutils
    # scl enable devtoolset-8 bash  #启动gcc8
    # echo "source /opt/rh/devtoolset-8/enable" >>/etc/profile
    # source /etc/profile
  3. 验证安装

    # gcc -v
    Using built-in specs.
    COLLECT_GCC=gcc
    COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-8/root/usr/libexec/gcc/x86_64-redhat-linux/8/lto-wrapper
    Target: x86_64-redhat-linux
    Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-8/root/usr --mandir=/opt/rh/devtoolset-8/root/usr/share/man --infodir=/opt/rh/devtoolset-8/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/isl-install --disable-libmpx --with-mpc=/builddir/build/BUILD/gcc-8.3.1-20190311/obj-x86_64-redhat-linux/mpc-install --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
    Thread model: posix
    gcc version 8.3.1 20190311 (Red Hat 8.3.1-3) (GCC)

配置 qtcreator

  1. Tools -> Options -> Build & Run -> Compilers -> Add -> GCC,Compiler path 指向 Qt 安装目录下 g++ 路径
    Centos 6 Install Qt 5.6.3

  2. Kits -> Add,选择我们刚刚创建的 Compiler
    Centos 6 Install Qt 5.6.3

测试 Qt 5.6.3

我选择了 QWebEngine 项目 demobrowser,可以看到编译及程序运行一切正常!
Centos 6 Install Qt 5.6.3

0 0 投票数
喜欢就给个好评吧!
赞(0) 打赏
未经允许不得转载:爱易默博客 » Centos 6 安装 Qt 5.6.3
订阅评论
提醒
guest

0 评论
内联反馈
查看所有评论
免责声明:本站大部分下载资源收集于网络,只做学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除,若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,与本站无关。本站发布的内容若侵犯到您的权益,请联系站长删除,我们将及时处理! Disclaimer: Most of the download resources on this site are collected on the Internet, and are only used for learning and communication. The copyright belongs to the original author. Please consciously delete within 24 hours after downloading. If you use it for commercial purposes, please purchase the original version. If the content posted on this site violates your rights, please contact us to delete it, and we will deal with it in time!

联系我们 Contact us

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏

0
希望看到您的想法,请您发表评论x