歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux 下編譯、安裝、配置 QT

Linux 下編譯、安裝、配置 QT

日期:2017/2/28 14:33:54   编辑:Linux教程

打算做嵌入式圖像處理,計劃方案嵌入式Linux+OpenCV+QT,昨天簡單入門OpenCV今天看看QT,QT就先弄Linux下面的,回家之前爭取把基本的摸通,然後能在板子上跑起來。

Qt 的詳細介紹:請點這裡
Qt 的下載地址:請點這裡

推薦閱讀:

Ubuntu 環境下Gtk與QT編譯環境安裝與配置 http://www.linuxidc.com/Linux/2013-08/88539.htm

Linux系統下QT環境搭建 http://www.linuxidc.com/Linux/2013-07/87576.htm

Ubuntu下QT控制台程序無法運行的解決方案以及XTerm的配置方法 http://www.linuxidc.com/Linux/2013-06/86244.htm

Ubuntu 10.04下QT4.7.4移植詳解 http://www.linuxidc.com/Linux/2013-01/77930.htm

Linux下為剛安裝好的Qt Creator 創建桌面啟動圖標 http://www.linuxidc.com/Linux/2012-08/67214.htm

Ubuntu 11.04安裝QT Creator 2.5.0 http://www.linuxidc.com/Linux/2012-06/62607.htm

Qt creator for PlayBook安裝過程 http://www.linuxidc.com/Linux/2012-05/60652.htm

軟件環境


Linux:Ubuntu 12.04 X86

QT:4.8.4

關於QT安裝


QT的早期版本和現在版本有點變化,提供的文件也不盡相同,最新的版本為5.0,我這裡用的是4.8.4,一個完整的QT應該包括QT庫、IDE也就是QT creator,在Linux下的安裝中,目前看到的主要有三種方法:

1、.bin文件直接安裝,文件名為qt-sdk-……,一個./bin直接包括了所有相關工具,安裝起來最為簡單方便,但是目前的4.8.4在幾個網站上已經找不到總的sdk的bin文件了,老版本的還是可以的。

2、Ubuntu下使用atp-get安裝,方法如下(未驗證)

sudo apt-get install qt4-dev-tools #開發包   
sudo apt-get install qtcreator #IDE  
sudo apt-get install qt4-doc #開發幫助文檔   
sudo apt-get install qt4-qtconfig #配置工具   
sudo apt-get install qt4-demos #DEMO源碼  QT

3、這就是本文用的方法,就是下載源碼包,自己編譯安裝,最為麻煩,但是本來就是學習的,況且現在只能下載到源碼包,那就先學習這種方法把。

軟件下載


QT有好幾個下載網站,這裡匯總介紹,自從諾基亞公司放棄Meego、遣散Qt開發團隊以後,Qt商業版本的網站移到了qt.digia.com,而開源版本則放到了qt-project.org :

1、首先是諾基亞的官方網站http://qt.digia.com/ 這個是不太方便的,想快速下載的接著看後面的。

此網站需要填寫用戶名和郵箱地址,下載地址會發送到郵件裡,我就把我收到的地址貼出來吧。下面是郵件中的地址匯總。這裡面的linux源碼是commercial版本。

Qt 4.8.4 for embedded Linux

http://dist.qt.digia.com/developer/download/qt-everywhere-commercial-src-4.8.4.tar.gz

Installing Qt for embedded Linux

http://qt-project.org/doc/qt-4.8/qt-embedded-install.html

Qt Commercial Charts 1.1.0

http://dist.qt.digia.com/developer/download_charts/qt-commercial-charts-src-1.1.0.tar.gz

Qt 5.0.0 Sources

http://dist.qt.digia.com/developer/download_50/qt-everywhere-commercial-src-5.0.0.tar.gz

Qt 4.8.4 for Windows (Src and VS2008 32bit Binary)

http://dist.qt.digia.com/developer/download/qt-win-commercial-4.8.4-vs2008.exe

Qt Visual Studio Addin 1.1.11 for Qt4 (Binary)

http://dist.qt.digia.com/developer/download/qt-vs-addin-1.1.11.exe

Qt 4.8.4 for Windows (Src and VS2010 32bit Binary)

http://dist.qt.digia.com/developer/download/qt-win-commercial-4.8.4-vs2010.exe

Qt 4.8.4 for Windows (Src and MinGW 32bit Binary)

http://dist.qt.digia.com/developer/download/qt-win-commercial-4.8.4-mingw.exe

Qt Creator 2.6.1 for Windows (32bit Binary)

http://dist.qt.digia.com/developer/download_creator/qt-creator-win-commercial-2.6.1.exe

Qt 4.8.4 for Windows (Src and VS2010 64bit Binary)

http://dist.qt.digia.com/developer/download/qt-win-commercial-4.8.4-vs2010-64bit.exe

Qt Commercial Charts 1.1.0

http://dist.qt.digia.com/developer/download_charts/qt-commercial-charts-src-1.1.0.zip

Qt 5.0.0 Sources

http://dist.qt.digia.com/developer/download_50/qt-everywhere-commercial-src-5.0.0.zip

Qt 5.0.0 Offline SDK for Windows (32-bit Binary)

http://dist.qt.digia.com/developer/download_50/qt-windows-commercial-5.0.0-msvc2010_32-x86-offline.exe

Qt Visual Studio Addin 1.2.0 for Qt5 (Binary)

http://dist.qt.digia.com/developer/download_50/qt-vs-addin-1.2.0.exe

2、QT-project網站下載 http://qt-project.org/downloads

這個網站就直接而且清晰多了,分類很清楚,如下圖所示。

需要說明的是Qt libraries 4.8.4 for embedded Linux (236 MB) 下載鏈接和Qt libraries 4.8.4 for Linux/X11 (225 MB) 其實下載的是一個東西,反正我看到的鏈接地址都是一樣的,這也就是Linux下我們需要用的。另外從這個頁面再下載開發所用的IDE QT Creator,這是一個bin文件,可以直接安裝。

QT的編譯與安裝


1、拷貝文件到自己想要的文件夾,解壓:

tar zxvf qt-everywhere-opensource-src-4.8.4.tar.gz

2、進入解壓後文件目錄,執行配置

root@emouse:~/study# cd qt-everywhere-opensource-src-4.8.4/

root@emouse:~/study/qt-everywhere-opensource-src-4.8.4# ./configure

此處也可以加上配置前綴./configure -prefix /opt/qt-4.8.4-x11

這樣的話再後面編譯過程中的文件會復制到/opt/qt-4.8.4-x11 這個目錄下(目錄不存在會自動創建),好處是源碼便於管理,

關於這部分前綴配置可以我在config文件中找到這部分代碼,可以參考,可以從這段代碼中看出相應的配置以及沒有配置的情況下默認安裝目錄,代碼位於3594行,如下:

#-------------------------------------------------------------------------------
# post process QT_INSTALL_* variables
#-------------------------------------------------------------------------------

#prefix
if [ -z "$QT_INSTALL_PREFIX" ]; then
if [ "$CFG_DEV" = "yes" ]; then
QT_INSTALL_PREFIX="$outpath" # In Development, we use sandboxed builds by default
elif [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" ]; then
if [ "$PLATFORM_QPA" = "yes" ]; then
QT_INSTALL_PREFIX="/usr/local/Trolltech/QtLighthouse-${QT_VERSION}"
else
QT_INSTALL_PREFIX="/usr/local/Trolltech/QtEmbedded-${QT_VERSION}"
fi
if [ "$PLATFORM" != "$XPLATFORM" ]; then
QT_INSTALL_PREFIX="${QT_INSTALL_PREFIX}-${CFG_ARCH}"
fi
elif [ -d "$EPOCROOT" ] && [ "$XPLATFORM_SYMBIAN" = "yes" ]; then
if [ "$XPLATFORM_SYMBIAN" = "yes" ]; then
QT_INSTALL_PREFIX="$EPOCROOT/epoc32/"
QT_INSTALL_LIBS="$EPOCROOT/epoc32/release/armv5/lib/"
fi
else
QT_INSTALL_PREFIX="/usr/local/Trolltech/Qt-${QT_VERSION}" # the default install prefix is /usr/local/Trolltech/Qt-$QT_VERSION

Copyright © Linux教程網 All Rights Reserved