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 [qt-project.org] depending your version of Ubuntu. The installation file can be also downloaded through the command line using wget.

Example:

  1. wget http : //download.qt-project.org/official_releases/qt/5.0/5.0.2/qt-linux-opensource-5.0.2-x86-offline.run

  • Install

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

  1. chmod  +x qt -linux -opensource -5.0.2 -x86 -offline. run
  2. . /qt -linux -opensource -5.0.2 -x86 -offline. run

  • Install g++

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

  1. sudo apt -get install build -essential

  • 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:

  1. 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 [qt-project.org] an additional package needs installation. Execute following command:

  1. 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.

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:

  1. sudo apt -get install build -essential

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

Solution:

  1. sudo apt -get install mesa -common -dev

Ubuntu 20.04上安装QT5,你可以按照以下步骤进行操作: 1. 首先,确保你已经安装了gcc编译器。你可以通过运行以下命令来检查是否安装了gcc: ``` gcc -v ``` 如果没有安装,你可以使用以下命令安装gcc: ``` sudo apt install gcc ``` 2. 接下来,检查是否安装了g++编译器。你可以通过运行以下命令来检查是否安装了g++: ``` g++ -v ``` 如果没有安装,你可以使用以下命令安装g++: ``` sudo apt install g++ ``` 3. 安装clang编译器。你可以使用以下命令安装clang: ``` sudo apt install clang ``` 4. 安装make工具。你可以使用以下命令安装make: ``` sudo apt install make ``` 5. 安装cmake。你可以使用以下命令安装最新版的cmake: ``` sudo snap install cmake --classic ``` 6. 安装Qt5的组件。你可以使用以下命令安装Qt5的组件: ``` sudo apt-get install build-essential ``` 7. 安装Qt的开发工具。你可以使用以下命令安装Qt的开发工具: ``` sudo apt-get install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools ``` 8. 安装qtcreator。你可以使用以下命令安装qtcreator: ``` sudo apt-get install qtcreator ``` 9. 安装qt。你可以使用以下命令安装qt: ``` sudo apt-get install qt5* ``` 如果你想使用在线安装包安装QT5,你可以按照以下步骤进行操作: 1. 首先,下载QT的在线安装包。你可以使用以下命令下载安装包: ``` wget https://download.qt.io/official_releases/online_installers/qt-unified-linux-x64-online.run ``` 2. 授予安装包可执行权限。你可以使用以下命令授予可执行权限: ``` sudo chmod +x qt-unified-linux-x64-online.run ``` 3. 在安装包所在的目录下运行安装包。你可以使用以下命令运行安装包: ``` ./qt-unified-linux-x64-online.run ``` 这样,你就可以在Ubuntu 20.04上成功安装QT5了。希望对你有帮助!
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值