Install Qt 5 on Ubuntu: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
(Added a note about how these instructions don't work for Ubuntu 16.04 LTS.)
(13 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:HowTo]]<br />[[Category:Tutorial]]<br />[[Category:QtCreator]]
{{LangSwitch}}


[toc align_right=&quot;yes&amp;quot; depth=&quot;2&amp;quot;]
[[Category:HowTo]]
 
[[Category:Tutorial]]
'''English''' [[Install_Qt_5_on_Ubuntu_Bulgarian|Български]]
[[Category:Tools::QtCreator]]


= Install Qt 5 on Ubuntu =
= Install Qt 5 on Ubuntu =
Line 9: Line 9:
== Introduction ==
== Introduction ==


This is a tutorial for installation of Qt 5.0.2 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.
This is a tutorial for installation of Qt 5.7.0 to Ubuntu 12.10. It may be used for some newer versions of Qt and Ubuntu. As a counterexample, Ubuntu 16.04 LTS uses an independent system for controlling the Qt version.  Following these directions for Ubuntu 16.04 results in an error where a file can't be found in a qt4 directory, even though you're installing qt5 not 4.  Another difference for OpenGL has been found and added as a note below.


== Installation Guide ==
== Installation Guide ==
Line 15: Line 15:
* '''Download'''
* '''Download'''


Visit Qt downloads page an &quot;download a 32-bit or 64-bit Linux installation&amp;quot;:http://qt.io/download depending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.
Visit Qt downloads page an [https://www.qt.io/download-open-source/#section-2 download a 32-bit or 64-bit Linux installation] depending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.


''Example:''<br /><code><br />wget http://download.qt.io/official_releases/qt/5.0/5.0.2/qt-linux-opensource-5.0.2-x86-offline.run<br /></code>
''Example:''
<code>
wget http://download.qt.io/official_releases/qt/5.7/5.7.0/qt-opensource-linux-x64-5.7.0.run
</code>


* '''Install'''
* '''Install'''
Line 23: Line 26:
Adjust permission, run the installer and follow the instruction to complete the installation.
Adjust permission, run the installer and follow the instruction to complete the installation.


<code><br />chmod +x qt-linux-opensource-5.0.2-x86-offline.run<br />./qt-linux-opensource-5.0.2-x86-offline.run<br /></code>
<code>
chmod +x qt-opensource-linux-x64-5.7.0.run
./qt-opensource-linux-x64-5.7.0.run
</code>
 
* '''Install g++'''
 
Open a terminal and execute the following command to install g++:
<code>
sudo apt-get install build-essential
</code>
 
* '''Install generic font configuration library - runtime'''


* '''Install g+''*
Open a terminal and execute the following command to install the full runtime files for the generic font configuration library:
<br />Open a terminal and execute the following command to install g''+:<br /><code><br />sudo apt-get install build-essential<br /></code>
<code>
<br />''' '''Configure a compiler'''
sudo apt-get install libfontconfig1
</code>


Launch '''Qt Creator'''. Go to '''Tools &gt; Options'''. Click '''Build &amp; Run''' and select tab '''Kit'''. Configure a compiler if it is not automatically detected.
*'''Configure a compiler'''
 
Launch '''Qt Creator'''. Go to '''Tools > Options'''. Click '''Build & Run''' and select tab '''Kit'''. Configure a compiler if it is not automatically detected.


* '''Install OpenGL libraries'''
* '''Install OpenGL libraries'''


Execute the following command to install OpenGL libraries:<br /><code><br />sudo apt-get install mesa-common-dev<br /></code>
Execute the following command to install OpenGL libraries:
<code>
sudo apt-get install mesa-common-dev
</code>


Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on this &quot;comment in the forum&amp;quot;:http://forum.qt.io/viewthread/23855/#110514 an additional package needs installation. Execute following command:<br /><code><br />sudo apt-get install libglu1-mesa-dev -y<br /></code><br />Tested with Qt5.3.1 and Ubuntu 14.04 and it solved the problem with missing -lGL.
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<ref>[https://forum.qt.io/topic/59062/qt-5-5-0-problem-running-examples-solved/2 Qt 5.5.0 problem running examples &#91;SOLVED&#93;]. 2015-09-22. [https://web.archive.org/web/20160801041947/https://forum.qt.io/topic/59062/qt-5-5-0-problem-running-examples-solved Archived] from the original on 2016-08-01. Retrieved 2016-08-01. <blockquote>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.</blockquote></ref> an additional package needs installation. Execute following command:
<code>
sudo apt-get install libglu1-mesa-dev -y
</code>
Tested with Qt5.3.1 and Ubuntu 14.04 and it solved the problem with missing -lGL.


* '''Set file association with pro files'''
* '''Set file association with pro files'''


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


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


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


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


<code><br />text/qtcreator=Qt-Creator.desktop;<br /></code>
<code>
text/qtcreator=Qt-Creator.desktop;
</code>


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


<code><br />application/vnd.nokia.qt.qmakeprofile=qtcreator.desktop<br /></code>
<code>
application/vnd.nokia.qt.qmakeprofile=qtcreator.desktop
</code>


if not add it under [added Associations].
if not add it under [added Associations].
Line 57: Line 100:
Run the following command.
Run the following command.


<code><br />sudo update-mime-database /usr/share/mime<br /></code>
<code>
sudo update-mime-database /usr/share/mime
</code>


now Qt has been added to the list of file associations.
now Qt has been added to the list of file associations.
Line 69: Line 114:
* '''error: g++: Command not found'''
* '''error: g++: Command not found'''


''Solution:''<br /><code><br />sudo apt-get install build-essential<br /></code>
''Solution:''
<code>
sudo apt-get install build-essential
</code>


* '''error: GL/gl.h: No such file or directory'''
* '''error: GL/gl.h: No such file or directory'''


''Solution:''<br /><code><br />sudo apt-get install mesa-common-dev
''Solution:''
<code>
sudo apt-get install mesa-common-dev
</code>
 
==References==
<div class="references-small">
<references />
</div>

Revision as of 19:09, 17 July 2018

En Ar Bg De El Es Fa Fi Fr Hi Hu It Ja Kn Ko Ms Nl Pl Pt Ru Sq Th Tr Uk Zh

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 for some newer versions of Qt and Ubuntu. As a counterexample, Ubuntu 16.04 LTS uses an independent system for controlling the Qt version. Following these directions for Ubuntu 16.04 results in an error where a file can't be found in a qt4 directory, even though you're installing qt5 not 4. Another difference for OpenGL has been found and added as a note below.

Installation Guide

  • Download

Visit Qt downloads page an download a 32-bit or 64-bit Linux installation depending 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 +x qt-opensource-linux-x64-5.7.0.run
./qt-opensource-linux-x64-5.7.0.run
  • Install g++

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

sudo apt-get install build-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:

sudo apt-get install libfontconfig1
  • Configure a compiler

Launch Qt Creator. Go to Tools > Options. Click Build & Run and select tab Kit. Configure a compiler if it is not automatically detected.

  • Install OpenGL libraries

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 a comment in the Qt forum[1] 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.

  • 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=1.0
Encoding=UTF-8
Type=Application
Name=QtCreator
Comment=QtCreator
NoDsiplay=true
Exec=(Install folder of QT)/Tools/QtCreator/bin/qtcreator %f
Icon=(Install folder of QT)/5.4/Src/qtdoc/doc/images/landing/icon_QtCreator_78x78px.png
Name[en_US]=Qt-Creator

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

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

text/qtcreator=Qt-Creator.desktop;

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

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

if not add it under [added Associations].

Run the following command.

sudo update-mime-database /usr/share/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:

sudo apt-get install build-essential
  • error: GL/gl.h: No such file or directory

Solution:

sudo apt-get install mesa-common-dev

References

  1. Qt 5.5.0 problem running examples [SOLVED]. 2015-09-22. Archived from 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.