| 如何建立Qt/Embedded開發環境 |
| |
|
| |
FriendlyARM |
| |
|
| |
本文適用於友善之臂基於S3C2410X的任何一種目標板 |
| |
注意:為了保證您能夠正確執行本文的步驟,請務必按照“ 完整安裝Redhat 9.0 Step by Step”一文正確安裝您的Redhat 9.0系統 |
| |
|
|
| |
|
| |
1. 解壓原始碼,配置Qt庫的路徑 |
| |
2. 使用build指令碼編譯Qt/Embedded |
| |
3. Hello,SBC-2410X for X86 |
| |
4. Hello,SBC-2410X for ARM |
| |
5. 常見的編譯錯誤 |
|
| |
|
| |
1. 解壓原始碼,配置Qt庫的路徑 |
| |
|
| |
把光碟片放入DVD-ROM,執行以下步驟: |
| |
Step1 掛接光碟片 #mount /dev/cdrom /mnt/cdrom Step2 進入Qt 開發包目錄 #cd /mnt/cdrom/SBC-2410X-Linux/EmGUI Step3 安裝X86 版本的Qt 和Qtopia 原始碼 #tar xvzf x86-qtopia.tgz –C /friendly-arm #該步將在/friendly-arm下產生x86-qtopia目錄 Step4 安裝SBC-2410X 版本的Qtopia 原始碼 #tar xvzf arm-qtopia.tgz –C /friendly-arm #該步將在/friendly-arm目錄下產生arm-qtopia目錄 Step5 彈出光碟片 #cd / #eject |
| |
|
| |
為了在PC上類比運行Qtopia,需要用到對應Qt版本的庫檔案,因此需要修改/etc/ld.so.conf檔案以適應剛剛安裝的Qt(Redhat安裝時帶有Qt庫,但不適合我們最新安裝的版本),修改後的ld.so.conf檔案內容如下: /friendly-arm/x86-qtopia/qt/lib /friendly-arm/x86-qtopia/qtopia/lib /usr/kerberos/lib /usr/X11R6/lib /usr/lib/sane /usr/lib/mysql |
| |
|
|
| |
|
| |
2. 使用build指令碼編譯Qt/Embedded |
| |
|
| |
(1)編譯Qt/Embedded for X86 |
| |
#cd /friendly-arm/x86-qtopia #./build (該過程比較長,需要運行大概30分鐘左右) #ldconfig |
| |
註:運行ldconfig是為了使產生的qt和qtopia庫有效,運行一次即可。 |
| |
|
| |
(2) 在PC上類比運行Qtopia |
| |
#qvfb& |
| |
#qtopia |
| |
|
| |
|
|
| |
|
| |
3. Hello,SBC-2410X for X86 |
| |
|
| |
(1)編譯Hello, SBC-2410X |
| |
#cd /friendly-arm/x86-qtopia #. set-env ;注意,中間有個空格,必須要有才能執行有效! #cd hello #make |
| |
將在/friendly-arm/x86-qtopia/qtopia/bin目錄下產生hello可執行檔 |
| |
|
| |
(2)單獨運行Hello, SBC-2410X |
| |
#qvfb -width 640 -height 480 & |
| |
#hello -qws |
| |
|
| |
在qvfb中單獨運行Hello, SBC-2410X |
| |
|
| |
(3)在Qtopia中運行Hello, SBC-2410X |
| |
#qvfb -width 640 -height 480 & |
| |
#qpe |
| |
|
| |
在qtopia中的Hello, SBC-2410X |
| |
|
|
| |
|
| |
4. Hello,SBC-2410X for ARM |
| |
|
| |
(1)編譯Qt/Embedded for ARM |
| |
#cd /friendly-arm/arm-qtopia #./build (該過程比較長,需要運行大概30分鐘左右) |
| |
|
| |
(2)編譯Hello, SBC-2410X for ARM |
| |
#cd hello #make |
| |
編譯完畢,hello將產生存在/friendly-arm/arm-qtopia/qtopia/bin目錄下 |
| |
|
| |
(3)把hello下載到目標板 |
| |
將可執行檔移動到 SBC-2410X 目前主要有兩種方式: |
| |
第一種方法:複製到介質(下面以優盤為例) |
| |
#mount /dev/sda1 /mnt #cp hello /mnt #umount /mnt 把優盤拔下來插入到 SBC-2410X 的 USB HOST 連接埠,按照以下命令操作: #mount /dev/sda1 /mnt ;掛接優盤 #cp /mnt/hello /opt/qtopia/bin ;把 hello 複製到/opt/qtopia/bin目錄 |
| |
|
| |
第二種方法: 通過網路移動(推薦使用) |
| |
通過網路下載程式的主要步驟是:先把 hello 複製到 ftp 共用目錄,然後在 SBC-2410X 上使用 ftp 下載,並修改執行許可權運行,如下: 在 PC 端執行: #cp hello /home/ftp ;把 hello 複製到 ftp 共用目錄 在SBC-2410X 端執行: #cd /opt/qtopia/bin ;進入bin目錄 #ftp 192.168.0.1 ;登入ftp伺服器 >get hello ;下載 hello >bye ;退出 ftp 登入 #chmod a+x hello ;改變 hello 的可執行許可權 |
| |
|
| |
(4)在目標板上單獨運行hello |
| |
export set HOME=/root export set QTDIR=/opt/qt export set QPEDIR=/opt/qtopia export set QWS_KEYBOARD="USB:/dev/input/event1" export set QWS_MOUSE_PROTO="USB:/dev/input/mouse0" export set PATH=$QPEDIR/bin:$PATH export set LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/lib $QPEDIR/bin/hello -qws |
| |
|
| |
(5)在Qtopia中運行hello |
| |
export set HOME=/root export set QTDIR=/opt/qt export set QPEDIR=/opt/qtopia export set QWS_KEYBOARD="USB:/dev/input/event1" export set QWS_MOUSE_PROTO="USB:/dev/input/mouse0" export set PATH=$QPEDIR/bin:$PATH export set LD_LIBRARY_PATH=$QTDIR/lib:$QPEDIR/lib $QPEDIR/bin/qpe > /dev/null 2>/dev/null |
| |
|
|
| |
|
| |
5. 常見的編譯錯誤 |
| |
|
| |
(1) 執行build時出現的錯誤 |
| |
./build 很長時間後,最後顯示如下 Makefiles will be regenerated. ................................................................................. QPE is now configured for building. Just run "make". To reconfigure, run make clean and configure. make -C libraries/qtopia make[1]: Entering directory `/friendly-arm/x86-qtopia/qtopia/src/libraries/qtopia' make[1]: Nothing to be done for `default'. make[1]: Leaving directory `/friendly-arm/x86-qtopia/qtopia/src/libraries/qtopia' make -C 3rdparty/libraries/freetype make[1]: Entering directory `/friendly-arm/x86-qtopia/qtopia/src/3rdparty/libraries/freetype' make[1]: Nothing to be done for `default'. make[1]: Leaving directory `/friendly-arm/x86-qtopia/qtopia/src/3rdparty/libraries/freetype' make -C libraries/qtopia1 make[1]: Entering directory `/friendly-arm/x86-qtopia/qtopia/src/libraries/qtopia1' g++ -c -I/friendly-arm/x86-qtopia/qtopia/include -I/friendly-arm/x86-qtopia/qt/include -pipe -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W -DNO_DEBUG -fPIC -DQTOPIA_APP_INTERFACE -I.moc/linux-generic-g++/ -I/friendly-arm/x86-qtopia/qtopia/src/server -o .obj/linux-generic-g++//global1.o global1.cpp global1.cpp:39:23: uuid/uuid.h: 沒有那個檔案或目錄 global1.cpp: In static member function `static QUuid Global::generateUuid()': global1.cpp:188: `::uuid_generate' undeclared (first use here) make[1]: *** [.obj/linux-generic-g++//global1.o] Error 1 make[1]: Leaving directory `/friendly-arm/x86-qtopia/qtopia/src/libraries/qtopia1' make: *** [libraries/qtopia1] Error 2 |
| |
這是因為你沒有正確安裝Redhat 9.0所致,請參考 “ 完整安裝Redhat 9.0 Step by Step”一文正確安裝您的Redhat 9.0系統 |
| |
|
| |
(2) 編譯hello時出現的錯誤 |
| |
資訊如下: |
| |
/usr/lib/qt-3.1/bin/uic hello_base.ui -o ./hello_base.h g++ -c -I/include -I/usr/lib/qt-3.1/include -pipe -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W -DNO_DEBUG -DQTOPIA_APP_INTERFACE -I.moc/linux-generic-g++/ -o .obj/linux-generic-g++//hello.o hello.cpp g++ -c -I/include -I/usr/lib/qt-3.1/include -pipe -DQWS -fno-exceptions -fno-rtti -O2 -Wall -W -DNO_DEBUG -DQTOPIA_APP_INTERFACE -I.moc/linux-generic-g++/ -o .obj/linux-generic-g++//main.o main.cpp main.cpp:2:35: qtopia/qpeapplication.h: No such file or directory main.cpp: In function `int main(int, char**)': main.cpp:6: `QPEApplication' undeclared (first use this function) main.cpp:6: (Each undeclared identifier is reported only once for each function it appears in.) main.cpp:6: parse error before `(' token main.cpp:9: `a' undeclared (first use this function) main.cpp:5: warning: unused parameter `int argc' main.cpp:5: warning: unused parameter `char**argv' make: *** [.obj/linux-generic-g++//main.o] Error 1 |
| |
從錯誤資訊中可以看出,編譯hello的時候這裡用的是-I/include標頭檔目錄,這個目錄是不正確的,導致這樣的原因是:您沒有在build完之後運行ldconfig命令! |
| |
|
| |
(3) 編譯hello時出現的第二種錯誤 |
| |
錯誤資訊如下: |
| |
[root@localhost hello]# make /usr/lib/qt-3.1/bin/uic hello_base.ui -o ./hello_base.h /usr/lib/qt-3.1/bin/uic: error while loading shared libraries: libqt-mt.so.3: cannot open shared object file: No such file or directory make: *** [hello_base.h] Error 127 |
| |
從錯誤資訊中可見,您的x86-qtopia環境並沒有搭建好,亦然使用redhat9.0內建的環境。解決辦法如下: |
| |
第一種辦法:請務必在同一個視窗執行以上步驟。運行build指令碼時,已經包含了環境的建立,您不能離開build運行後所在的視窗環境來編譯hello |
| |
第二種辦法:自己建立重新建立環境。即使用/friendly-arm/x86-qtopia/set-env指令碼。運行時請務必使用“. set-env ”,注意中間有個空格 |
| |
,同樣,您不能離開set-env運行後所在的視窗環境來編譯hello |