【QT】Linux下安装QT开发环境

Linux下安装QT开发环境

零、下载安装包

从以下网址可以下载QT的所有版本:

https://download.qt.io/

这次演示安装5.9.0版本,因为是长期支持的版本,所以进入到archive/qt/5.9/5.9.0

这里,我们是Linux,因此选择Linux版本的安装包,点击文件名下载并保存文件。如果下载较慢建议使用迅雷等下载工具。

安装包下载地址:https://download.qt.io/archive/qt/5.9/5.9.0/qt-opensource-linux-x64-5.9.0.run

壹、安装

下载完成后打开终端,进入到下载目录,一般在 ~/下载 文件夹(输入不了中文可以用ls命令列出后复制过去)。

给安装包分配运行权限

命令:

chmod +x qt-opensource-linux-x64-5.9.0.run

运行安装程序,进入到安装界面

命令:

./qt-opensource-linux-x64-5.9.0.run

需要登录,可以点Skip跳过

选择安装组件,根据自己的需要勾选需要安装的组件,但是建议这样选择(带QT的和gcc全选)

之后根据向导一步一步来就能安装好了~

贰、错误解决

一般安装好之后会遇到两个问题

一个提示,执行qmake时出错

15:50:56: Could not determine which "make" command to run. Check the "make" step in the build configuration.
Error while building/deploying project planets-qml (kit: Desktop Qt 5.9.0 GCC 64bit)

When executing step "qmake"

另一个提示,找不到lGL

../../../../5.9/gcc_64/include/QtGui/qopengl.h:139:13: fatal error: GL/gl.h: No such file or directory
  139 | #   include <GL/gl.h>
      |             ^~~~~~~~~
compilation terminated.
make: *** [Makefile:1009: main.o] Error 1
15:55:01: 进程"/usr/bin/make"退出,退出代码 2 。
Error while building/deploying project planets-qml (kit: Desktop Qt 5.9.0 GCC 64bit)
When executing step "Make"

原因是没安装对应的软件。

解决第一个错误:

sudo apt install cmake g++

解决第二个错误:

sudo apt install libgl1-mesa-dev

叁、结果

执行上述操作后,能正常编译运行示例:

肆、参考:

http://c.biancheng.net/view/3851.html

http://c.biancheng.net/view/3886.html

http://c.biancheng.net/view/3858.html

https://blog.csdn.net/aaa123524457/article/details/82668194

原文地址:https://www.cnblogs.com/minuy/p/14430897.html