Ubuntu18.04上安裝Qt5.10的步驟實(shí)踐
Qt是一個跨平臺的C++圖形用戶界面庫,我們平時所說所使用的Qt,準(zhǔn)確的來說是它的GUI編程部分。Qt提供給應(yīng)用程序開發(fā)者建立圖形用戶界面所需要的功能,并且Qt很容易擴(kuò)展?;旧?,Qt和X Window上的Motif、Openwin、GTK等圖形界面庫和Windows平臺上的MFC、OWL、VCl以及ATl是相同類型的東西。

一.安裝Qt
第一步:
官網(wǎng)http://download.qt.io/archive/qt/ 下載安裝包,
或者國內(nèi)網(wǎng)址下載 https://mirrors.tuna.tsinghua.edu.cn/qt/archive/qt/5.9/5.9.0/
我安裝的是QT5.10.1 中的 qt-opensource-linux-x64-5.10.1.run ;
第二步:ctrl+T 打開終端輸入命令:
sudo chmod -R 777 qt-opensource-linux-x64-5.10.1.run
第三步:開始安裝 Qt(安裝路徑有下列兩種方式) ,終端輸入命令:
第一種安裝方式:
./qt-opensource-linux-x64-5.10.1.run // 將Qt默認(rèn)安裝在home目錄下。
第二種安裝方式:
sudo ./qt-opensource-linux-x64-5.10.1.run //將Qt安裝在/opt目錄
一般選擇后者安裝。
第四步:根據(jù)彈出的窗口,按照提示,一直點(diǎn)擊 next,再點(diǎn)擊 skip,之后一直點(diǎn)擊 next,直到這一步,注意,如圖,將所有選項(xiàng)打“√”,點(diǎn)擊 next,即可,然后等待安裝;

二.配置環(huán)境
第一步:Qt 安裝完成后,先別打開,因?yàn)檫€需要安裝其他工具以及庫文件。
第二步:打開終端,輸入命令:
sudo apt-get install gcc g++ //安裝 linux 下編程的編譯器
第三步:繼續(xù)輸入命令:
sudo apt-get install libqt4-dev //不然編譯時會出現(xiàn)錯誤“cannot find -lgl
第四步:輸入命令:
sudo apt-get install build-essential //它可以使得我們的程序知道頭文件和庫函數(shù)放在哪個位置
第五步:打開 Qt,首先進(jìn)入到Qt的安裝目錄下
第一種安裝方式采用:
cd /home/sikui/Qt5.7.0/Tools/QtCreator/bin/ //Qt安裝在home下
第二種安裝方式采用:
cd /opt/Qt5.7.0/Tools/QtCreator/bin/ //Qt安裝在/opt下
進(jìn)入到安裝目錄里面后輸入:
./qtcreator //運(yùn)行Qt成功
注意:Qt運(yùn)行報(bào)錯問題
1.新建project運(yùn)行編譯是報(bào)錯“Could not determine which “make” command to run。這是由于新安裝的ubuntu缺少cmake及g++造成的。
終端輸入:
sudo apt-get install cmake g++
然后打開Qt,在工具 -> 選項(xiàng) -> 構(gòu)建和運(yùn)行 -> 構(gòu)建套件Kit 進(jìn)行設(shè)置,編譯器這一項(xiàng)的C及C++選型選擇正確的GCC版本。

2.如果編譯完成后運(yùn)行,報(bào)錯”cannot find -lGL“
sudo apt-get install libgl1-mesa-dev
關(guān)于安裝中碰到下面問題
如果編譯出錯:
找不到-lEGL,說明需要安裝opengl庫
切換apt-get源
切換到阿里的源
sudo vim /etc/apt/sources.list
安裝
# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial universe deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties deb http://archive.canonical.com/ubuntu xenial partner deb-src http://archive.canonical.com/ubuntu xenial partner deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
到此這篇關(guān)于Ubuntu18.04上安裝Qt5.10的步驟實(shí)踐的文章就介紹到這了,更多相關(guān)Ubuntu18.04安裝Qt5.10內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C++內(nèi)存數(shù)據(jù)結(jié)構(gòu)與二進(jìn)制文件之間的序列化和反序列化方式
這篇文章主要介紹了C++內(nèi)存數(shù)據(jù)結(jié)構(gòu)與二進(jìn)制文件之間的序列化和反序列化方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2023-08-08
C++基于easyx圖形庫實(shí)現(xiàn)打磚塊游戲
這篇文章主要為大家詳細(xì)介紹了C++基于easyx圖形庫實(shí)現(xiàn)打磚塊游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-05-05
C/C++運(yùn)用WMI接口實(shí)現(xiàn)查詢系統(tǒng)信息
Windows?Management?Instrumentation(WMI)是一種用于管理和監(jiān)視Windows操作系統(tǒng)的框架,本文主要介紹了如何運(yùn)用WMI接口實(shí)現(xiàn)查詢系統(tǒng)信息,感興趣的可以了解下2023-11-11
C++?opencv實(shí)現(xiàn)在圖片上畫一條線示例代碼
這篇文章主要為大家介紹了C++?opencv實(shí)現(xiàn)在圖片上畫一條線的示例代碼,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-05-05

