日韩黑丝制服一区视频播放|日韩欧美人妻丝袜视频在线观看|九九影院一级蜜桃|亚洲中文在线导航|青草草视频在线观看|婷婷五月色伊人网站|日本一区二区在线|国产AV一二三四区毛片|正在播放久草视频|亚洲色图精品一区

分享

Linux 下編譯、安裝、配置 QT

 風之library 2014-09-30

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

軟件環(huán)境


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 #開發(fā)包   
sudo apt-get install qtcreator #IDE  
sudo apt-get install qt4-doc #開發(fā)幫助文檔   
sudo apt-get install qt4-qtconfig #配置工具   
sudo apt-get install qt4-demos #DEMO源碼  QT

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

軟件下載


QT有好幾個下載網站,這里匯總介紹,自從諾基亞公司放棄Meego、遣散Qt開發(fā)團隊以后,Qt商業(yè)版本的網站移到了qt.,而開源版本則放到了  :

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

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

Qt 4.8.4 for embedded Linux

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

Installing Qt for embedded Linux

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

Qt Commercial Charts 1.1.0

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

Qt 5.0.0 Sources

http://dist.qt./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./developer/download/qt-win-commercial-4.8.4-vs2008.exe

Qt Visual Studio Addin 1.1.11 for Qt4 (Binary)

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

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

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

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

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

Qt Creator 2.6.1 for Windows (32bit Binary)

http://dist.qt./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./developer/download/qt-win-commercial-4.8.4-vs2010-64bit.exe

Qt Commercial Charts 1.1.0

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

Qt 5.0.0 Sources

http://dist.qt./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./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./developer/download_50/qt-vs-addin-1.2.0.exe

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

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

image

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

QT的編譯與安裝


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

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

2、進入解壓后文件目錄,執(zhí)行配置

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 這個目錄下(目錄不存在會自動創(chuàng)建),好處是源碼便于管理,

關于這部分前綴配置可以我在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
復制代碼

配置過程中會有以下提示:

Which edition of Qt do you want to use ?

Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.

當然選擇o啦。繼續(xù)提示:

復制代碼
This is the  Open Source Edition.

You are licensed to use this software under the terms of
the Lesser GNU General Public License (LGPL) versions 2.1.
You are also licensed to use this software under the terms of
the GNU General Public License (GPL) versions 3.

Type '3' to view the GNU General Public License version 3.
Type 'L' to view the Lesser GNU General Public License version 2.1.
Type 'yes' to accept this license offer.
Type 'no' to decline this license offer.

Do you accept the terms of either license?
復制代碼

輸入yes,回車即可。接下來就會生成makefile文件,配置過程十來分鐘左右。配置完畢后執(zhí)行make。

接下來可以吃個飯或者睡一覺,編譯時間大概3個小時左右,比較漫長,耐心等待吧。

經過漫長的等待之后,執(zhí)行sudo make install來安裝,會安裝到/usr/local/Trolltech/Qt-4.8.4目錄下。安裝時間比較短,大概需要幾分鐘左右,至此,安裝完成。

小測試一下,運行 /usr/local/Trolltech/Qt-4.8.4/bin/designer ,看見 qt 啟動,如下圖所示,就說明QT已經安裝成功。

image

其他配置


qmake這個命令需要進行環(huán)境變量的配置才能找到的到,我看了下我的系統(tǒng)里已經包含了這個命令了,只是路徑不一樣。測試如下:

root@emouse:/# qmake -v
Qmake version: 1.07a (Qt 3.3.8b)
Qmake is free software from Trolltech ASA.
root@emouse:/# which qmake
/usr/bin/qmake

在看一下qmake的屬性

image

從這個地方可以看出qmake這個命令別鏈接到了/etc/alternatives/qmake,還是不清楚是啥地方來的命令,繼續(xù)看!找到/etc/alternatives/qmake,在看一下屬性就清楚了,可以看到這個地方又鏈接回去了,那么如果還使用qmake命令的話實際使用的是qmake-qt3,這樣就會出現錯誤。image也可以使用以下命令快速查看:

root@emouse:/# ls /usr/bin/qmake -ln
lrwxrwxrwx 1 0 0 23 12月 14 21:06 /usr/bin/qmake -> /etc/alternatives/qmake
root@emouse:/# ls /etc/alternatives/qmake -ln
lrwxrwxrwx 1 0 0 18 12月 14 21:06 /etc/alternatives/qmake -> /usr/bin/qmake-qt3

通過以上的分析可以知道,解決這個問題有兩種方法,一個就是更改qmake的鏈接,使得qmake這個命令鏈接到安裝目錄下我們安裝版本的qmake,還有一種方法就是改環(huán)境變量。

先說更改鏈接的方法,通過上面的介紹,這個其實操作就比較直接和簡單了,命令和實驗結果如下:

root@emouse:/# rm /etc/alternatives/qmake 
root@emouse:/# ln -s /usr/local/Trolltech/Qt-4.8.4/bin/qmake /etc/alternatives/qmake
root@emouse:/# qmake -v
QMake version 2.01a
Using Qt version 4.8.4 in /usr/local/Trolltech/Qt-4.8.4/lib

可以看到,qmake已經成功更改為4.8.4版本。

第二種辦法就是更改環(huán)境變量,這個我沒有嘗試,有興趣的自己驗證。

vi /home/defonds/.bashrc 用來修改用戶環(huán)境變量,在文件后面添加以下信息

export QTDIR=/usr/local/Trolltech/Qt-4.8.4 
export PATH=$QTDIR/bin:$PATH  
export MANPATH=$QTDIR/man:$MANPATH  
export LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

再修改所有用戶環(huán)境變量vi /etc/profile 同樣在文件后添加上面的環(huán)境變量信息。這種方法應該同樣可行。

Qt-creator的安裝與配置


根據上面提供的網址下載qt creator在linux下的安裝文件qt-creator-linux-x86-opensource-2.6.1.bin,下面的安裝就比較簡單了,首先更改文件屬性,使它可執(zhí)行。

chmod u+x qt-creator-linux-x86-opensource-2.6.1.bin

然后運行sudo ./qt-creator-linux-x86-opensource-2.6.1.bin

接下來就是非常熟悉的安裝界面了。

image

安裝完成即可。接下來就可以使用這個IDE來進行開發(fā)了,這樣的界面是不是在linux下很難得呢?

image

 

初步的安裝就到這里,下次繼續(xù)寫關于嵌入式開發(fā)平臺的構建。

    本站是提供個人知識管理的網絡存儲空間,所有內容均由用戶發(fā)布,不代表本站觀點。請注意甄別內容中的聯系方式、誘導購買等信息,謹防詐騙。如發(fā)現有害或侵權內容,請點擊一鍵舉報。
    轉藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多