environment:
* host: ubuntu 10.04
* client: target board(?)
1. Get Source
host$ cd ~
host$ wget http://get.qt.nokia.com/qt/source/qt-everywhere-opensource-src-4.6.2.tar.gz
host$ tar zxvf qt-everywhere-opensource-src-4.6.2.tar.gz
2. Settup Toolchain
2-1) add toolchain to environment variable
host$ vim ~/.bashrc
export MY_TOOLCHAIN=/path/to/toolchain # add this line export PATH=$PATH:$MY_TOOLCHAIN # add this line
host$ source ~/.bashrc
3. Qmake
3-1) http://en.wikipedia.org/wiki/Qmake
3-2) modify [/path/to/qt]/mkspecs/qws/linux-arm-g++/qmake.conf
include(../../common/g++.conf) include(../../common/linux.conf) include(../../common/qws.conf) QMAKE_CC = /path/to/toolchain/gcc QMAKE_CXX = /path/to/toolchain/g++ QMAKE_LINK = /path/to/toolchain/g++ QMAKE_LINK_SHLIB = /path/to/toolchain/g++ QMAKE_AR = /path/to/toolchain/ar cqs QMAKE_OBJCOPY = /path/to/toolchain/objcopy QMAKE_STRIP = /path/to/toolchain/strip load(qt_config)
3-3) modify fancybrowser
host$ cd ~/qt-everywhere-opensource-src-4.6.2/example/webkit/fancybrowser
host$ vim main.cpp
#include#include "mainwindow.h" int main(int argc, char * argv[]) { QApplication app(argc, argv, QApplication::GuiServer); QTextCodec *codec = QTextCodec::codecForName("UTF-8"); // add this line for supporting UTF-8 encodeing QTextCodec::setCodecForLocale(codec); // add this line QTextCodec::setCodecForCStrings(codec); // add this line QTextCodec::setCodecForTr(codec); // add this line QFont font("wenquanyi",6); // add this line for setting font name app.setFont(font); // add this line MainWindow browser; browser.show(); return app.exec(); }
host$ vim mainwindow.cpp
//! [2] view = new QWebView(this); view->load(QUrl("http://www.google.com.tw/")); view->settings()->setAttribute(QWebSettings::PluginsEnabled, true); // add this line view->settings()->setAttribute(QWebSettings::JavascriptEnabled, true); // add this line view->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true); // add this line connect(view, SIGNAL(loadFinished(bool)), SLOT(adjustLocation())); connect(view, SIGNAL(titleChanged(QString)), SLOT(adjustTitle())); connect(view, SIGNAL(loadProgress(int)), SLOT(setProgress(int))); connect(view, SIGNAL(loadFinished(bool)), SLOT(finishLoading(bool)));
4. Config Parameters & Install
4-1) important parameter
-embedded arm // cross-compile for arm platform -xplatform qws/linux-arm-g++ // cross-compile for arm platform with linux-arm-g++ qmake -plugin-gfx-directfb // display with directfb through plugin
4-2) config with your library
host$ ./configure -embedded arm -xplatform qws/linux-arm-g++ -debug -fast -little-endian -no-largefile -accessibility -no-qt3support -webkit -javascript-jit -script -scripttools -qt-zlib -qt-gif -qt-libtiff -qt-libpng -qt-libmng -qt-libjpeg -no-dbus -no-mmx -no-3dnow -no-sse -no-sse2 -openssl -no-gtkstyle -no-nas-sound -no-opengl -no-openvg -no-sm -no-xshape -no-xsync -no-xinerama -xcursor -no-xfixes -no-xrandr -no-xrender -no-mitshm -no-fontconfig -no-xinput -no-xkb -freetype -no-neon -no-glib -plugin-gfx-directfb -I/path/to/directfb/header -ldirectfb -I/path/to/library/header -L/path/to/shared/library -lg -lssl -lcrypto -lz -lm -lpng -ljpeg -lfreetype -lpthread -v -confirm-license
host$ make
host$ sudo make install
4-3) add Chinese font support(download wenquanyi_120_50.qpf here)
host$ cd /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib
host$ sudo rm -f fonts/*
host$ sudo vim fontdir
wqx wenquanyi_120_50.qpf QPF n 50 120 wqx wenquanyi_120_75.qpf QPF n 75 120 wqx wenquanyi_130_50.qpf QPF n 50 130 wqx wenquanyi_130_75.qpf QPF n 75 130 wqx wenquanyi_150_50.qpf QPF n 50 150 wqx wenquanyi_150_75.qpf QPF n 75 150 wqx wenquanyi_160_50.qpf QPF n 50 160 wqx wenquanyi_160_75.qpf QPF n 75 160
host$ sudo cp [/path/to]/wenquanyi_120_50.qpf fonts
4-4) copy shared library instead of symbolic link
host$ cd /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib
host$ sudo cp libQtNetwork.so.4.6.2 libQtNetwork.so.4
host$ sudo cp libQtNetwork.so.4.6.2 libQtNetwork.so.4.6
host$ sudo cp libQtNetwork.so.4.6.2 libQtNetwork.so
host$ sudo cp libQtGui.so.4.6.2 libQtGui.so.4
host$ sudo cp libQtGui.so.4.6.2 libQtGui.so.4.6
host$ sudo cp libQtGui.so.4.6.2 libQtGui.so
host$ sudo cp libQtCore.so.4.6.2 libQtCore.so.4
host$ sudo cp libQtCore.so.4.6.2 libQtCore.so.4.6
host$ sudo cp libQtCore.so.4.6.2 libQtCore.so
host$ sudo cp libQtXml.so.4.6.2 libQtXml.so.4
host$ sudo cp libQtXml.so.4.6.2 libQtXml.so.4.6
host$ sudo cp libQtXml.so.4.6.2 libQtXml.so
host$ sudo cp libQtMultimedia.so.4.6.2 libQtMultimedia.so.4.6
host$ sudo cp libQtMultimedia.so.4.6.2 libQtMultimedia.so.4
host$ sudo cp libQtMultimedia.so.4.6.2 libQtMultimedia.so
host$ sudo cp libQtScript.so.4.6.2 libQtScript.so.4.6
host$ sudo cp libQtScript.so.4.6.2 libQtScript.so.4
host$ sudo cp libQtScript.so.4.6.2 libQtScript.so
host$ sudo cp libQtScriptTools.so.4.6.2 libQtScriptTools.so.4.6
host$ sudo cp libQtScriptTools.so.4.6.2 libQtScriptTools.so.4
host$ sudo cp libQtScriptTools.so.4.6.2 libQtScriptTools.so
host$ sudo cp libQtSvg.so.4.6.2 libQtSvg.so.4.6
host$ sudo cp libQtSvg.so.4.6.2 libQtSvg.so.4
host$ sudo cp libQtSvg.so.4.6.2 libQtSvg.so
host$ sudo cp libQtWebKit.so.4.6.2 libQtWebKit.so.4.6
host$ sudo cp libQtWebKit.so.4.6.2 libQtWebKit.so.4
host$ sudo cp libQtWebKit.so.4.6.2 libQtWebKit.so
host$ sudo cp libQtSql.so.4.6.2 libQtSql.so.4
host$ sudo cp libQtSql.so.4.6.2 libQtSql.so.4.6
host$ sudo cp libQtSql.so.4.6.2 libQtSql.so
4-5) copy 3rd library (if configure with -openssl)
host$ sudo cp /path/to/libcrypto.so.1.0.0 .
host$ sudo cp /path/to/libssl.so.1.0.0 .
host$ sudo cp /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/libcrypto.so.1.0.0 libcrypto.so
host$ sudo cp /usr/local/Trolltech/QtEmbedded-4.6.2-arm/lib/libssl.so.1.0.0 libssl.so
5. Display Qt Application in Target Board
5-1) setting QtEmbedded-4.6.2-arm environment variable
client# QTDIR=/path/to/QtEmbedded-4.6.2-arm
client# export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$QTDIR/lib
client# export QT_QWS_FONTDIR=$QTDIR/lib/fonts
client# export QT_PLUGIN_PATH=$QTDIR/plugins
client# export QWS_DISPLAY=directfb
5-2) execute fancybrowser
client# cd /path/to/QtEmbedded-4.6.2-arm
client# cd examples/webkit/fancybrowser
client# ./fancybrowser
reference: Qt for Embedded Linux Environment Variables
沒有留言:
張貼留言