View Full Version : How can I build <<hello world>> example statically

10th January 2006, 13:54
Hello All !

I build QT's hello world example.
And ldd shows:

ldd qt
libQtGui_debug.so.4 => /usr/local/Trolltech/Qt-4.0.0/lib/libQtGui_debug.so.4 (0x00111000)
libpng12.so.0 => /usr/lib/libpng12.so.0 (0x00e1c000)
libSM.so.6 => /usr/X11R6/lib/libSM.so.6 (0x0067a000)
libICE.so.6 => /usr/X11R6/lib/libICE.so.6 (0x00682000)
libXi.so.6 => /usr/X11R6/lib/libXi.so.6 (0x00c3f000)
libXrender.so.1 => /usr/X11R6/lib/libXrender.so.1 (0x00699000)
libXrandr.so.2 => /usr/X11R6/lib/libXrandr.so.2 (0x006a1000)
libXcursor.so.1 => /usr/X11R6/lib/libXcursor.so.1 (0x00a44000)
libfreetype.so.6 => /usr/lib/libfreetype.so.6 (0x006a5000)
libfontconfig.so.1 => /usr/lib/libfontconfig.so.1 (0x006f5000)
libXext.so.6 => /usr/X11R6/lib/libXext.so.6 (0x00fe4000)
libX11.so.6 => /usr/X11R6/lib/libX11.so.6 (0x0078c000)
libQtCore_debug.so.4 => /usr/local/Trolltech/Qt-4.0.0/lib/libQtCore_debug.so.4 (0x0086b000)
libz.so.1 => /usr/lib/libz.so.1 (0x0071c000)
libdl.so.2 => /lib/libdl.so.2 (0x0072a000)
libpthread.so.0 => /lib/tls/libpthread.so.0 (0x0072d000)
libstdc++.so.6 => /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.0/libstdc++.so.6 (0x00a4d000)
libm.so.6 => /lib/tls/libm.so.6 (0x00cae000)
libgcc_s.so.1 => /usr/local/lib/gcc/i686-pc-linux-gnu/4.0.0/libgcc_s.so.1 (0x00c6f000)
libc.so.6 => /lib/tls/libc.so.6 (0x00cd0000)
libexpat.so.0 => /usr/lib/libexpat.so.0 (0x0073d000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x00a18000)

How can I build this example statically, i.e.
ldd ./hello-world
not a dynamic executable

OS - Red Hat Enterprise Linux 3 u5
gcc - 4.0.0
QT - 4.0.0
glibc - 2.3.2

10th January 2006, 15:30
Do you have the static version of the Qt-libs in your Qtdir? These are files with extension .a.

10th January 2006, 16:03
My QT installation is default (i don't remember static or shared).

10th January 2006, 16:07
Only *.so *.la *.prl

10th January 2006, 16:25
Then you will have to recompile Qt. ./configure of Qt has a flag to compile a static version of the lib. I'm not sure wether you can have both static and dynamic build at once in the same directory, so building in another directory might be wise.