Install Qt 5 on Ubuntu: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
'''English''' [[Install Qt 5 on Ubuntu Bulgarian|Български]]
[[Category:Tutorial]]<br />[[Category:QtCreator]]


=Install Qt 5 on Ubuntu=
[toc align_right=&quot;yes&amp;quot; depth=&quot;2&amp;quot;]


==Introduction==
'''English''' [[Install_Qt_5_on_Ubuntu_Bulgarian|Български]]
 
= Install Qt 5 on Ubuntu =
 
== 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.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.


==Installation Guide==
== Installation Guide ==


* '''Download'''
* '''Download'''


Visit Qt downloads page an [http://qt.io/download download a 32-bit or 64-bit Linux installation] ''[qt.io]'' depending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.
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.


''Example:''<br />
''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>


* '''Install'''
* '''Install'''
Line 19: Line 23:
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.


* '''Install g++'''
<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>


Open a terminal and execute the following command to install g++:<br />
* '''Install g+''*
 
<br />Open a terminal and execute the following command to install g''+:<br /><code><br />sudo apt-get install build-essential<br /></code>
* '''Configure a compiler'''
<br />''' '''Configure a compiler'''


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.
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.
Line 29: Line 33:
* '''Install OpenGL libraries'''
* '''Install OpenGL libraries'''


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


Note: Just installing the above-mentioned mesa-common-dev kit is not sufficient for more recent Ubuntu versions. Based on this [http://forum.qt.io/viewthread/23855/#110514 comment in the forum] ''[qt.io]'' an additional package needs installation. Execute following command:<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 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.


* '''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.<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.
 
<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>


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 .<br />Add the following line.
 
<code><br />text/qtcreator=Qt-Creator.desktop;<br /></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>


if not add it under [added Associations].
if not add it under [added Associations].


Run the following command.
Run the following command.
<code><br />sudo update-mime-database /usr/share/mime<br /></code>


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


==Troubleshooting==
== Troubleshooting ==


* '''Qt Creator needs a compiler set up to build'''
* '''Qt Creator needs a compiler set up to build'''
Line 57: Line 69:
* '''error: g++: Command not found'''
* '''error: g++: Command not found'''


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


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


''Solution:''<br />
''Solution:''<br /><code><br />sudo apt-get install mesa-common-dev
 
===Categories:===
 
* [[:Category:HowTo|HowTo]]
* [[:Category:QtCreator|QtCreator]]
* [[:Category:Tutorial|Tutorial]]

Revision as of 12:47, 23 February 2015


[toc align_right="yes&quot; depth="2&quot;]

English Български

Install Qt 5 on Ubuntu

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.

Installation Guide

  • Download

Visit Qt downloads page an "download a 32-bit or 64-bit Linux installation&quot;:http://qt.io/download depending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.

Example:

<br />wget http://download.qt.io/official_releases/qt/5.0/5.0.2/qt-linux-opensource-5.0.2-x86-offline.run<br />
  • Install

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

<br />chmod +x qt-linux-opensource-5.0.2-x86-offline.run<br />./qt-linux-opensource-5.0.2-x86-offline.run<br />
  • 'Install g+*


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

<br />sudo apt-get install build-essential<br />


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:

<br />sudo apt-get install mesa-common-dev<br />

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&quot;:http://forum.qt.io/viewthread/23855/#110514 an additional package needs installation. Execute following command:

<br />sudo apt-get install libglu1-mesa-dev -y<br />


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.

<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 />

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

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

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

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

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

if not add it under [added Associations].

Run the following command.

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

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:

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

Solution:

sudo apt-get install mesa-common-dev