歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> Linux CentOS 系統下安裝 QT

Linux CentOS 系統下安裝 QT

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

雙休日期間,在Linux CentOS 系統下安裝了QT,花了二天時間,剛安裝完....記錄下酸甜苦辣....我的系統是 CenttOS5.5

具體的安裝辦法:

1、前往這裡下載Qt 4.5.3 for X11 OpenSource 版。

2、下載過來的是 qt-x11-opensource-src-4.5.3.tar.gz文件,我們用tar命令解壓一下。

tar zxvf qt-x11-opensource-src-4.5.3.tar.gz

3、把這個目錄移到/usr/local目錄下,或者不移,放在/home或其它目錄都可以。下面的安裝過程是把這個目錄移到/usr/local目錄下,改名為qt ;如果您沒有移動,在設置的時候注意目錄。

4、修改(可以使用vi編輯器 或gedit)自己目錄下的.bash_profile 或者 .profile或者是/etc/profile這個文件,如:#vi /root/.bash_profile 或#vi .bash_profile 或#vi /etc/profile 或 #vi .profile

加入下面的代碼:

QTDIR=/usr/local/qt
PATH=$QTDIR/bin:$PATH
MANPATH=$QTDIR/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QTDIR PATH MANPATH LD_LIBRARY_PATH

5、注銷一下用戶或者 #source /root/.bash_profile 一下,使配置文件生效。如果第4步是#vi .bash_profile,則應該是:# source .bash_profile ,其它情況依此類推。

6、有時,Linux/CentOS系統沒有g++包或g++的部分包 ,請在終端輸入如下命令:

yum install libX*

7、進入QT 的目錄,開始編譯

./configure

輸入yes同意GPL/QPL協議。

在網絡上還看到這個命令 ./configure -thread,為了支持多線程,大家還是敲一下這些命令好了。./configure -thread 和 ./configure 命令,我都試過了,沒有重復,./configure -thread運行時間比./configure要短得多。

運行完./configure有如下提示:

Qt is now configured for building. Just run 'gmake'.

Once everything is built, you must run 'gmake install'.

Qt will be installed into /usr/local/Trolltech/Qt-4.5.3

To reconfigure, run 'gmake confclean' and 'configure'.

8、開始make ,這步要很長時間,從中午12點開始直到第二天凌晨5點我醒來時還沒運行完。

make

根據第6運行完命令./configure後的提示,我們或者可以輸入以下命令,即:

gmake(我使用此命令)

9、開始install (網上的一些手冊沒有這步,會出現 error while loading shared libraries: libQTDesignerComponents.so4 錯誤,我make install一下之後,就OK了。 )這步也要挺久的,我的機器花了大概一個多小時。

make install

根據第6運行完命令./configure後的提示,我們或者可以輸入以下命令,即:

gmake install(我使用此命令)

10、進入QT的目錄,進入bin目錄,然後運行 ./designer,大家可以看到圖形界面了吧。

更多CentOS相關信息見CentOS 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=14

Copyright © Linux教程網 All Rights Reserved