通過buildroot配置編譯好qtopia後,下載到開發板上,配置好環境變量:
export QWS_DISPLAY="LinuxFb:mmWidth480:mmHeight272:0"
export QWS_SIZE="480x272"
export LD_LIBRARY_PATH=/usr/lib
然後去運行demo程序,出現:
# /usr/demos/chip/chip -qws
QFontDatabase: Cannot find font directory /home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr/lib/fonts - is Qt installed correctly?
Aborted
【解決過程】
1.由於之前已經摺騰了關於qtopia的配置並編譯,所以,對於qt的官方的文檔中的這部分說明:
http://qt.nokia.com/doc/qtopia4.3/running-qtopia.html
“Environment Settings to Run Qtopia
There are no specific environment variables required to run Qtopia, however there are some that can be set to control Qtopia's features.
If you specified you will need to set LD_LIBRARY_PATH so that the libraries can be found.
Qtopia does not require to be set but third party applications may expect it to include .
You may wish to set some environment variables to configure Qtopia Core. You may also need to set QTOPIA_PHONE_DEVICE. See Qtopia Environment Variables for details on how to set environment variables.
”
應該還算理解了其意思,說的是,如果你當初編譯qtopia的時候,在./configure 中加了-no-rpath,根據說明:
“ -no-rpath .......... Do not use the library install path as a runtime
library path.
+ -rpath ............. Link Qt libraries and executables using the library
install path as a runtime library path. Equivalent
to -R install_libpath
”
意思就是,不要使用你的安裝路徑,即-prefix指定的路徑,如果沒用-prefix指定,那麼就是默認的/usr/local/Trolltech/QtEmbedded-4.5.3:
“ -prefix <dir> ...... This will install everything relative to <dir>
(default /usr/local/Trolltech/QtEmbedded-4.5.3)”
而我這裏當初配置的是-prefix $(TARGET_DIR)/usr,即 -prefix /home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr意思是將qtopia安裝到buildroot中rootfs中的usr下面。
並且,按照其說明,不需要配置其他環境變量了,只是由於編譯的時候,加了-no-rpath,所以需要配置一下對應的LD_LIBRARY_PATH,這裏由於之前配置成/home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr,buildroot中make的時候,編譯qt並make install到對應的rootfs文件夾的usr下面了,而現在rootfs已經燒寫到板子了,已經進了rootfs了,所以要配置成/usr/lib,以便qt程序運行的時候,能找到對應的庫文件。
所以,其他參數,應該就沒有再需要配置的了,應該就可以工作的了。
而且,關於
http://qt.nokia.com/doc/qtopia4.3/qtopiacore-envvars.html
中,也介紹了,關於qt-core的一些環境變量,主要是QWS_DISPLAY,我這裏,也按照網上別人的帖子和官方文檔中的說明,去配置了:
export QWS_DISPLAY="LinuxFb:mmWidth480:mmHeight272:0"
export QWS_SIZE="480x272"
或
export QWS_DISPLAY="LinuxFb:/dev/fb0"
了,但是,還是無法工作,運行測試程序,還是顯示錯誤:
# /usr/demos/mainwindow/mainwindow -qws
QFontDatabase: Cannot find font directory /home/crifan/buildroot/buildroot-2009.08/project_build_arm/uclibc/root/usr/lib/fonts - is Qt installed correctly?
最後,無意間,在網上看到別人的帖子:
http://hi.baidu.com/a263238386/blog/item/6ff055dda933033e5882dd32.html
發現有個關於qt font的環境變量:export QT_QWS_FONTDIR=$QTDIR/lib/fonts
所以,自己就去加了一下:
export QT_QWS_FONTDIR=/usr/lib/fonts
export LD_LIBRARY_PATH=/usr/lib
或者
export QTDIR=/usr
export LD_LIBRARY_PATH=$QTDIR/lib
export QT_QWS_FONTDIR=$QTDIR/lib/fonts
結果,qt的demo程序就可以運行了,呵呵。
實際結果表明,這些相關的qt的環境變量,是必須的,要指定好對應的位置,讓qt能找到qt的lib和font等必須的資源,纔可以運行qt的demo和example的。
其他的參數,好像這個,可有可無的:
export QT_PLUGIN_PATH=$QTDIR/plugins/
如果用到鼠標和鍵盤,那估計
http://qt.nokia.com/doc/qtopia4.3/qtopiacore-envvars.html
中的QWS_MOUSE_PROTO和QWS_KEYBOARD 也要配置好的。有空再去試試。
【提示】
1.關於-prefix參數,爲何不用qt默認的配置的/usr 而去自己修改爲$(TARGET_DIR)/usr:
因爲默認的qt.mk中原先配置的是 -prefix /usr,會去講qtopia安裝到我buildroot所在Linux的/usr下面,很弱智的,這樣,你buildroot中去make,最後的qtopia的make install會去將生成的qt的東西,用於arm板子的qt的東西,會安裝到你當前X86的PC上的Linux下的/usr中,這不扯淡的嗎。。
所以,纔會去在buildroot中package/qt.mk中,配置成QT_CONFIGURE += -prefix $(TARGET_DIR)/usr
【引用】
1。Online Reference Documentation
http://qt.nokia.com/doc/qtopia4.3/index.html
2.Qtopia Developer Resources
http://qt.nokia.com/doc/qtopia4.3/index.html
3.Running Qtopia
http://qt.nokia.com/doc/qtopia4.3/running-qtopia.html
4.Qtopia Core Environment Variables
http://qt.nokia.com/doc/qtopia4.3/qtopiacore-envvars.html
5.QT 4.5.2 嵌入式開發平臺的搭建
http://hi.baidu.com/a263238386/blog/item/6ff055dda933033e5882dd32.html
6.環境變量QWS_DISPLAY
http://fanzhichao.blog.hexun.com/23669000_d.html
另外一個: