2010-02-17

Build Qt as Static Library

Your Qt applications could be smaller and most importantly can be distributed as a single executable, if it is statically linked with Qt library.

A static built Qt application is faster. According to the artical "Qt Performance Tuning":

"A lot of CPU and memory is used by the ELF (Executable and Linking Format) linking process. Significant savings can be achieved by using a static build of the application suite; rather than having a collection of executables which link dynamically to Qt's libraries, all the applications is built into into a single executable which is statically linked to Qt's libraries."

First of all, you need to build Qt as a static library. See the thread http://lists.trolltech.com/qt-interest/2003-05/thread00396-0.html
./configure -thread -static  (makes libqt-mt.a)
./configure -static (makes libqt.a)
./configure (makes libqt.so)
./configure -thread (makes lib-mt.so)
Then, add the necessary plugins. See the artical http://doc.trolltech.com/4.6/plugins-howto.html#static-plugins.

Finally, deploy your application. See the artical http://doc.trolltech.com/4.6/deployment.html.

References:

2010-02-16

Useful Tar Commands

List the contents of tar file
>tar -tvf file.tar

List the contents of a tar.gz file
>tar -ztvf file.tar.gz

tar all .cc and .h files into a tar file named foo.tgz use
>tar cvzf foo.tgz *.cc *.h

extract only one (or several) files
>tar xvzf foo.tgz

extract only one (or several) files
>tar xvzf foo.tgz anagram.cc

extract bz2 tar ball
>tar -jxvf filename.tar.bz2

extract bz2 
>bunzip filename.bz2

Virtualization vs. Emulation

Virtualization and Emulation are two concepts that quite often used in the context of virtual machine. Some softwares can emulate the machine, some can virualize the machine and some can both (e. g. QEMU). After googling for some time, Max found some comparison on them:

"Emulation involves emulating the virtual machines hardware and architecture. Microsoft's VirtualPC is an example of an emulation based virtual machine. It emulates the x86 architecture, and adds a layer of indirection and translation at the guest level, which means VirtualPC can run on different chipsets, like the PowerPC, in addition to the x86 architecture. However, that layer of indirection slows down the virtual machine significantly."

"Virtualization, on the other hand, involves simply isolating the virtual machine within memory. The host instance simply passes the execution of the guest virtual machine directly to the native hardware. Without the translation layer, the performance of a virtualization virtual machine is much faster and approaches native speeds. However, since the native hardware is used, the chipset of the virtual machine must match. Usually, this means the Intel x86 architecture. VMWare is an example of this type of application for Windows."

Reference:

2010-02-15

Setup sb2 enviroment for mini2440

1) download CodeSourcery cross-compiler toolchain from http://www.codesourcery.com/sgpp/lite/arm/portal/subscription?@template=lite Note: Select the toolchain of Linux/GNU.

2) Extract the tar ball and arm-2009q3 is generated
>tar -jxvf arm-2009q3-67-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

3) Extract the root_qtopia root
>mkdir root_qtopia
>cd root_qtopia
>tar xvfz ../root_qtopia.tar.gz

4) Copy following directory to root_qtopia
>cp -a $HOME/arm-2008q3/arm-none-linux-gnueabi/libc/{lib,etc,usr} ${root_qtopia}

5) Generate sb2 target
>cd ${root_qtopia}
>sb2-init mini2440_qtopia /disk1/packages/arm-2009q3/bin/arm-none-linux-gnueabi-gcc
>sb2-config -d mini2440_qtopia

6) Compile an example code test.c

#include <stdio.h>
int factorial(int n)
{
if (n == 0) return 1;
return n * factorial (n - 1);
}

int main () {
int i;
int n;
for (i = 0; i < 10; ++i) {
n = factorial (i);
printf ("factorial(%d) = %d\n", i, n);
}
return 0;
}


>sb2
>gcc test.c -o test

7) To execute it, you need install qemu-arm
>git clone git://git.savannah.nongnu.org/qemu.git
>cd qemu
>./configure --target-list=arm-linux-user
>make
>make install
>make && make install

Then /usr/local/bin/qemu-arm is installed.




8) Try to execute
>sb2 test
/bin/bash: ./factorial: No such file or directory

9) run sb2-show to find out a library is missing in path
>sb2-show
sb2-show: error while loading shared libraries: libsb2.so.1: cannot open shared object file: No such file or directory,
due to the bug of sb2 package in debain

Solution: download the newest version and reinstall sb2
... to be continued

Filesystem Hierarchy Standard (FHS)

===========================================
A FHS standard compatible root has the following structure:
===========================================
binEssential command binaries
bootStatic files of the boot loader
devDevice files
etcHost-specific system configuration
libEssential shared libraries and kernel modules
mediaMount point for removeable media
mntMount point for mounting a filesystem temporarily
optAdd-on application software packages
sbinEssential system binaries
srvData for services provided by this system
tmpTemporary files
usrSecondary hierarchy
varVariable data
===============================
/usr hierarchy
===============================
binMost user commands
includeHeader files included by C programs
libLibraries
localLocal hierarchy (empty after main installation)
sbinNon-vital system binaries
shareArchitecture-independent data


Reference:
http://proton.pathname.com/fhs/pub/fhs-2.3.html

Buildroot vs OpenEmbedded

Slowly, buildroot is going to be replaced by OpenEmbedded. Here the citation from http://docs.openembedded.org/usermanual/

"Writing of BitBake recipes is more easy and more intuitive than writing Makefiles while providing higher flexibility. This allows you to tweak specific recipes for your very special needs and to add new recipes very fast. You can build toolchains, Software Distribution Kits (SDKs), complete Distributions or just single packages. The flexibility of OpenEmbedded allows you to reuse the once written recipes for many different purposes. OpenEmbedded provides everything buildroot will be able to provide. But in contrast to buildroot OpenEmbedded will allow you to achieve what you really want to achieve. You can add new package formats, new filesystems, new output formats easily. OpenEmbedded will suit your need."