chrishowells.co.uk

February 8, 2009

Building a fully static application with Qt and qmake

I’m trying to statically compile a Qt application. There are lots of google hits for instructions on doing this, but none of the instructions actually appear to be complete, or indeed work.

Configuring Qt with -static is the easy bit, I built Qt with the following options:


chris@thinky:~/qt-embedded-linux-opensource-src-4.4.3$ ./configure -embedded x86 -static -fast -no-exceptions -no-stl -no-accessibility -no-qt3support -no-xmlpatterns -no-phonon -no-phonon-backend -no-svg -no-webkit -no-sse -no-3dnow -no-sse2 -qt-zlib -qt-gif -qt-libtiff -qt-libpng -no-libmng -qt-libjpeg -no-openssl -no-nis -no-cups -no-iconv -no-dbus -no-freetype -qt-gfx-linuxfb -no-glib

Then as I already have Qt 4 installed on my system due to KDE, need to set $PATH to run the correct tools:


export PATH=/home/chris/qt-embedded-linux-opensource-src-4.4.3/bin:$PATH

I decided to modify the t1 example as a test, so I modified the t1.pro file, by adding ’static’ to the CONFIG line


chris@thinky:~/qt-embedded-linux-opensource-src-4.4.3/examples/tutorials/tutorial/t1$ cat t1.pro
TEMPLATE = app
CONFIG += qt warn_on static
HEADERS =
SOURCES = main.cpp
TARGET = t1

#QTDIR_build:REQUIRES="contains(QT_CONFIG, small-config)"

chris@thinky:~/qt-embedded-linux-opensource-src-4.4.3/examples/tutorials/tutorial/t1$ qmake -config release
chris@thinky:~/qt-embedded-linux-opensource-src-4.4.3/examples/tutorials/tutorial/t1$ make clean && make
rm -f .obj/release-static-emb-x86/main.o
rm -f *~ core *.core
g++ -c -pipe -fno-exceptions -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../../../mkspecs/qws/linux-x86-g++ -I. -I../../../../include/QtCore -I../../../../include/QtCore -I../../../../include/QtNetwork -I../../../../include/QtNetwork -I../../../../include/QtGui -I../../../../include/QtGui -I../../../../include -I.moc/release-static-emb-x86 -I.uic/release-static-emb-x86 -o .obj/release-static-emb-x86/main.o main.cpp
g++ -fno-exceptions -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.4.3/lib -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.4.3/lib -o t1 .obj/release-static-emb-x86/main.o -L/home/chris/qt-embedded-linux-opensource-src-4.4.3/lib -lQtGui -L/home/chris/qt-embedded-linux-opensource-src-4.4.3/lib -lQtNetwork -lQtCore -lm -lrt -lpthread -ldl

However, the binary is still dynamically linked:


chris@thinky:~/qt-embedded-linux-opensource-src-4.4.3/examples/tutorials/tutorial/t1$ file t1
t1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), not stripped
chris@thinky:~/qt-embedded-linux-opensource-src-4.4.3/examples/tutorials/tutorial/t1$ ldd t1
linux-gate.so.1 => (0xffffe000)
librt.so.1 => /lib/tls/i686/cmov/librt.so.1 (0xb7fb5000)
libpthread.so.0 => /lib/tls/i686/cmov/libpthread.so.0 (0xb7f9d000)
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0xb7f98000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0xb7ea5000)
libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7e80000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0xb7e75000)
libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7d2b000)
/lib/ld-linux.so.2 (0xb7fdc000)

Google seems to be out of results, and I appear to be out of ideas, as does the official Qt documentation.

Speaking to a Qt developer (who shall rename nameless to preserve his sanity, although I appreciate his help :), you can configure qmake to make a fully static app by adding the following line to the qmake config:


QMAKE_LFLAGS += -static

After running qmake again, this leads to the following:


chris@thinky:~/qt-embedded-linux-opensource-src-4.4.3/examples/tutorials/tutorial/t1$ make
g++ -c -pipe -fno-exceptions -O2 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE -I../../../../mkspecs/qws/linux-x86-g++ -I. -I../../../../include/QtCore -I../../../../include/QtCore -I../../../../include/QtNetwork -I../../../../include/QtNetwork -I../../../../include/QtGui -I../../../../include/QtGui -I../../../../include -I.moc/release-static-emb-x86 -I.uic/release-static-emb-x86 -o .obj/release-static-emb-x86/main.o main.cpp
g++ -fno-exceptions -static -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.4.3/lib -Wl,-rpath,/usr/local/Trolltech/QtEmbedded-4.4.3/lib -o t1 .obj/release-static-emb-x86/main.o -L/home/chris/qt-embedded-linux-opensource-src-4.4.3/lib -lQtGui -L/home/chris/qt-embedded-linux-opensource-src-4.4.3/lib -lQtNetwork -lQtCore -lm -lrt -lpthread -ldl
/home/chris/qt-embedded-linux-opensource-src-4.4.3/lib/libQtCore.a(qlibrary_unix.o): In function `QLibraryPrivate::load_sys()':
qlibrary_unix.cpp:(.text+0x307): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/chris/qt-embedded-linux-opensource-src-4.4.3/lib/libQtCore.a(qfsfileengine_unix.o): In function `QFSFileEngine::owner(QAbstractFileEngine::FileOwner) const':
qfsfileengine_unix.cpp:(.text+0x838): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
qfsfileengine_unix.cpp:(.text+0x736): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/home/chris/qt-embedded-linux-opensource-src-4.4.3/lib/libQtNetwork.a(qhostinfo_unix.o): In function `QHostInfoAgent::fromName(QString const&)':
qhostinfo_unix.cpp:(.text+0x30e): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Not good. It turns out that linking statically to glibc is hard, because getXXbyYY such as getpwuid_r require NSS, which is a loadable module….

Next step is to try compiling Qt against uClibc.

February 7, 2009

Liverpool’s Three Graces by night: Royal Liver Buliding, Cunard Building, Port of Liverpool Building

I took a series of images at the recent LivLug meeting and stitched them into this panorama, I’m quite pleased how it turned out. It’s not as good as it could be as I was trying to work quickly, on account of it being very cold indeed that evening. Will have to revisit during the summer and re-take it.

Canon EOS 20D, 100-400mm L, 10 second exposure, f/10.

Liverpool's Three Graces by night: Royal Liver Buliding, Cunard Building, Port of Liverpool Building, Pier Head, Liverpool
(click for larger version)

January 10, 2009

Windows 7 beta1 first impressions

I downloaded and installed Windows 7 beta1 and unfortunately my first impressions are somewhat poor (yes, I *know* it’s beta1, and it’s meant to be broken ;). The installer was quite easy to use, although it was slow.

After installation, I installed the NVidia drivers from Windows Update, as well as a couple of other things like Lightroom, DVB Viewer, and the Technotrend drivers. After rebooting the result was a blue screen of death.

The familiar BSOD STOP error: “A problem has been detected and Windows has been shut down to prevent damage to your computer”. “Attempt to reset the display driver and recover from timeout failed.” The error is in nvlddmkm.sys.

Windows 7 blue screen of death (BSOD)

This results in the familiar “Safe mode or not” on the next boot…

Windows 7 blue screen of death (BSOD)

January 5, 2009

WD TV is a GPL violation

I first started looking at the WD TV because I was interested in buying one, and once I found out that it was running Linux, started to investigate if I could customise it to my needs.

Update:  9th Feb 2009. WD released a new source code package some time ago (WDTV_GPL_Code.zip version 1.01.02), but it’s still a GPL violation. See below.

Disclaimer: I Am Not A Lawyer, nor do I have expert knowledge of GPL enforcement. I am merely a free software enthusiast and *nix sysadmin.

Unfortunately the WD TV product, by the well known hard disk manufacturer Western Digital, appears to be violating the copyright of various free software projects, including those of the GNU and mtd-tools projects.

Of most concern to the GNU project is that a “toolchain” consisting of a binary-only version of gcc is provided. Of concern to mtd-tools is that the firmware contains a binary version of mtd-tools, but no source code appears to be provided.

Personally I think that it is unacceptable that WD is making money out of violating the GPL, and effectively distributing pirated software. There would be an uproar if WD was using pirated Microsoft software, for instance.

Information

The firmware and “source code” is available from
http://support.wdc.com/product/download.asp?groupid=1001&sid=112〈=en

The first problem is that the “source code” is only for version 1.00.01, while the binary version is 1.01.01.

(more…)

December 31, 2008

Dear HBOS,

I know you’re in a bit of trouble right now with the whole worldwide credit crunch thing, but allowing me to update my phone numbers still doesn’t really count as an “offer”.

Halifax

December 29, 2008

Nero 9: a bloated heap of rubbish aka, how to turn DV into DVD without it

The disaster that is Nero

My father has rather a lot of camcorder tapes going back to the early 90s from three camcorders, an old analog Hi8 which was discarded due to it breaking and a Sony DCR-TRV120E Digital8 which we still have. At this was starting to deteriorate, a Canon HV20, which uses HDV, was purchased. The plan was to use the firewire output on both cameras to capture the video and turn it into a DVD as a backup.

My father has previous tried to use the Nero 8 “super ultimate edition” (or whatever it’s called) trial to convert the tapes to DVD, but he found that it took forever, and then didn’t burn the disk properly. We reinstalled his computer, which didn’t help, and contacted Nero technical support. They didn’t help either, as they didn’t reply. Apparently they don’t care about people who are using the trial version who are having problems.

I decided to capture the DV using WinDV, but then use Nero 9 (a massive 380MB, plus .NET 3.0) to do the processing, i.e. turning it into a DVD. This worked a few times, but then just stopped working. It would spend an hour or two encoding the video, then suddenly decide that it couldn’t burn it, generating the following error.

[02:00:34] DVDEngine SEH EXCEPTION (0xC0000005: ACCESS_VIOLATION) was raised in NEEM2V.DLL at RVA 0x00025342.

Great. Well, rather than waste my life trying to debug Windows and Nero, I decided to find another solution, mostly using tools I’d already used before.

An alternative solution using free utilities

(more…)

September 4, 2008

LivLug

I went to Liverpool for the first time in a year yesterday. Despite Liverpool being so close, I don’t have much need to go there these days, working in Manchester. I was reminded how much I miss the place, having been a student there for four years. It was quite sad to see all the houses on Edge Lane marked for demolition.

Things I miss about Liverpool: The buildings, the architecture, the history, most of the people

Things I don’t miss about Liverpool (which I unfortunately experienced): Having smelly old men come up to you and say “‘Ere lad, can you lend us 20p?”.

June 29, 2008

How to install Debian without a CD/DVD or netbooting

I was running Ubuntu 7.10 on my server, but wanted to reinstall it with Debian etch. The machine in question doesn’t have a CD/DVD-ROM drive, and I couldn’t be bothered to set up a tftp server on my laptop so I could netboot it. The answer? Set up the existing grub to boot the network installer kernel and initrd (initial RAM disk).

The files you need are here and here. (You’ll need some different files if you don’t want the x86 version, that is left as an excercise for the reader)

Just stick them into your /boot/, configure /boot/grub/menu.lst with something like this:

title Debian etch installer
root (hd0,0)
kernel /boot/linux vga=normal
initrd /boot/initrd.gz

Since the initrd contains everything you need including the installer and network driver modules, and only gets read once (when booting), you can of course overwrite the partition that these files are stored on (though if you mess up the installation it’ll be a bit harder to get it re-started ;)

« Newer Posts

Powered by WordPress