Linux下安裝QT開發環境
零、下載安裝包
從以下網址可以下載QT的所有版本:
這次演示安裝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