1、首先,我們必須確保gcc安裝好了,其次應用程序安裝了windows x server軟件包,也就是x11窗口吧,最好有桌面環境
2、前提工作到位後,我們就開始下載軟件包來安裝了,我下載的是qt-x11-opensource-src-4.4.3.tar.bz2
3、把軟件包放在/usr/local/myfile目錄下,解壓,tar jxvf qt-x11-opensource-src-4.4.3.tar.bz2
進入qt-x11-opensource-src-4.4.3
4、輸入./configure,運行shell腳本程序
5、開始編譯:gmake
gmake出錯:
In file included from ssl/qsslcertificate.cpp:117:
ssl/qsslsocket_openssl_symbols_p.h:264: error: variable or field ‘q_sk_free’ declared void
ssl/qsslsocket_openssl_symbols_p.h:264: error: ‘STACK’ was not declared in this scope
ssl/qsslsocket_openssl_symbols_p.h:264: error: ‘a’ was not declared in this scope
ssl/qsslsocket_openssl_symbols_p.h:265: error: ‘STACK’ was not declared in this scope
ssl/qsslsocket_openssl_symbols_p.h:265: error: ‘a’ was not declared in this scope
ssl/qsslsocket_openssl_symbols_p.h:266: error: ‘STACK’ was not declared in this scope
ssl/qsslsocket_openssl_symbols_p.h:266: error: ‘a’ was not declared in this scope
ssl/qsslsocket_openssl_symbols_p.h:266: error: expected primary-expression before ‘int’
ssl/qsslsocket_openssl_symbols_p.h:266: error: initializer expression list treated as compound expression
ssl/qsslcertificate.cpp: In member function ‘QMultiMap<QSsl::AlternateNameEntryType, QString> QSslCertificate::alternateSubjectNames() const’:
ssl/qsslcertificate.cpp:372: error: ‘STACK’ was not declared in this scope
ssl/qsslcertificate.cpp:372: error: ‘altNames’ was not declared in this scope
ssl/qsslcertificate.cpp:372: error: expected primary-expression before ‘)’ token
ssl/qsslcertificate.cpp:372: error: expected ‘;’ before ‘q_X509_get_ext_d2i’
ssl/qsslcertificate.cpp:393: error: ‘q_sk_free’ was not declared in this scope
gmake[1]: *** [.obj/release-shared-emb-x86/qsslcertificate.o] Error 1
gmake[1]: Leaving directory `/home/sysabod/qt-embedded-linux-opensource-src-4.4.3/src/network'
gmake: *** [sub-network-make_default-ordered] Error 2
原因可能是openssl服務沒有裝,我裝了這個服務好像還是有同樣的錯誤
解決辦法1:在configure的時候加個參數 -no-openssl
使用./configure -no-openssl 把openssl屏蔽掉嗎?
我使用這個方法解決問題的,然後重新gmake
解決方法2:
ln -s /usr/kerberos/include/com_err.h /usr/include/com_err.h
ln -s /usr/kerberos/include/profile.h /usr/include/profile.h
ln -s /usr/kerberos/include/krb5.h /usr/include/krb5.h
我用這個方法不行,仍然報錯
6、開始安裝:gmake install
注意軟件默認安裝到了/usr/local/Trolltech/Qt-4.4.3/目錄下,如果你不希望安裝到此目錄,在configure配置的時候使用-prefix選項設定
需要安裝的目錄
7、設置環境變量:
打開/etc/profile文件,在該文件的末尾加上以下語句:
PATH=/usr/local/Trolltech/Qt-4.4.3/bin:$PATH
QTDIR=/usr/local/Trolltech/Qt-4.4.3
MANPATH=$QTDIR/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export PATH QTDIR MANPATH LD_LIBRARY_PATH
執行source /etc/profile命令使配置生效
我遇到中文顯示亂碼的功能,解決辦法如下:
運行:/usr/local/qt4.3.2/bin/qtconfig,在Font項將字體設置爲Bitstream charter
退出保存。
8、測試
進入/usr/local/Trolltech/Qt-4.4.3/examples/desktop/systray
執行./systray命令,如果安裝好了就會出現如下界面:
也可以寫一個簡單的hello.cpp程序,測試編譯器是否有問題
#include <QApplication>
#include <QLabel>
int main(int argc,char *argv[])
{
QApplication app(argc,argv);
QLabel *label = new QLabel("Hello Yuan!");
label->show();
return app.exec();
}
執行qmake -project ; qmake ; make ; ./hello 一系列命令就可以出現如下界面