Install Qt 5 on Ubuntu

前端之家收集整理的这篇文章主要介绍了Install Qt 5 on Ubuntu前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Install Qt 5 on Ubuntu

Introduction

This is a tutorial for installation of Qt 5.7.0 to Ubuntu 12.10. It may be used also for newer versions of Qt and Ubuntu. A difference for OpenGL has been found and added as a note below.

Installation Guide

  • Download

Visit Qt downloads page andownload a 32-bit or 64-bit Linux installationdepending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.

Example:

wget http://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-linux-x64-5.7.0.run
  • Install

Adjust permission,run the installer and follow the instruction to complete the installation.

chmod @H_403_50@+x qt@H_301_56@-opensource@H_301_56@-linux@H_301_56@-x64@H_301_56@-5.7.0.run .@H_301_56@/qt@H_301_56@5.7.0.run
  • Install g++

Open a terminal and execute the following command to install g++:

sudo apt@H_301_56@-get install build@H_301_56@-essential
  • Install generic font configuration library - runtime

Open a terminal and execute the following command to install the full runtime files for the generic font configuration library:

-get install libfontconfig1
  • Configure a compiler

LaunchQt Creator. Go toTools > Options. ClickBuild & Runand select tabKit. Configure a compiler if it is not automatically detected.

  • Install OpenGL libraries

Execute the following command to install OpenGL libraries:

-get install mesa@H_301_56@-common@H_301_56@-dev

Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on a comment in the Qt forum[1]an additional package needs installation. Execute following command:

-get install libglu1@H_301_56@-mesa@H_301_56@-dev @H_301_56@-y

Tested with Qt5.3.1 and Ubuntu 14.04 and it solved the problem with missing -lGL.

  • Set file association with pro files

When installing from the on-line source the file association is not done automatically. It also not show up when you try to associate it with file explorer. Create a file named “Qt-Creator.desktop” and fill the file with the following.

[Desktop Entry] Version@H_301_56@=1.0 Encoding@H_301_56@=UTF@H_301_56@-8 Type@H_301_56@=Application Name@H_301_56@=QtCreator Comment@H_301_56@=QtCreator NoDsiplay@H_301_56@=true Exec@H_301_56@=(Install folder of QT)@H_301_56@/Tools@H_301_56@/QtCreator@H_301_56@/bin@H_301_56@/qtcreator @H_301_56@%f Icon@H_301_56@/5.4@H_301_56@/Src@H_301_56@/qtdoc@H_301_56@/doc@H_301_56@/images@H_301_56@/landing@H_301_56@/icon_QtCreator_78x78px.png Name[en_US]@H_301_56@=Qt@H_301_56@-Creator

Place this file in home .local/share/applications .

Edit a file named “defaults.list” in the same directory . Add the following line.

text@H_301_56@/qtcreator@H_301_56@-Creator.desktop;

open file mimeapps.list and check if the following line is present.

application@H_301_56@/vnd.nokia.qt.qmakeprofile@H_301_56@=qtcreator.desktop

if not add it under [added Associations].

Run the following command.

sudo update@H_301_56@-mime@H_301_56@-database @H_301_56@/usr@H_301_56@/share@H_301_56@/mime

now Qt has been added to the list of file associations.

Troubleshooting

  • Qt Creator needs a compiler set up to build

Follow the instruction from the prevIoUs section to configure compiler for Qt Creator.

  • error: g++: Command not found

Solution:

  • error: GL/gl.h: No such file or directory
  • -dev

    References

    1. Jump upQt 5.5.0 problem running examples [SOLVED]. 2015-09-22.Archivedfrom the original on 2016-08-01. Retrieved 2016-08-01.
      Execute the following command to install OpenGL libraries: sudo apt-get install mesa-common-dev Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on this comment in the forum an additional package needs installation. Execute following command: sudo apt-get install libglu1-mesa-dev -y Tested with Qt5.3.1 and Ubuntu 14.04 and it solved the problem with missing -lGL.

    原文地址:http://wiki.qt.io/Install_Qt_5_on_Ubuntu

    原文链接:https://www.f2er.com/ubuntu/349288.html

    猜你在找的Ubuntu相关文章