Image

Imagesimbab wrote in Imagelinux 🤔curious Liverpool, NY

[ot] Static Linking

I have a Qt application I need to run on Mac OS X. It's going to be a "portable" application, as in, download the .app bundle inside a ZIP file and run it. No installs, no admin privileges assumed. Due to the way Mac OS X works, it is possible to take a regular, dynamically-linked executable that is linked to Qt and put the .dylib binaries (libQtCore.4.dylib, etc.) inside the bundle and the linker will find them.

This is pretty expensive in terms of application size, however, considering I am download the app from my home server which only has a 1Mbps uplink. If I split the Universal binaries into separate bundles and compress them in ZIP files, a single (i386 or ppc) download weighs in at about 6MB. This is not bad, but I wondered if I could go one better by using static linking to include Qt.

My question is this—is static linking intelligent enough to jettison functions of Qt that I don't touch at all, thus potentially further reducing the size of the resultant binary? I tried static linking on Linux and came up with a binary that was about 6MB, or around 3MB compressed using gzip or ZIP.

I can also configure out things I don't need (e.g. WebKit, SQL support, Qt3 compatibility) since I have to self-compile Qt anyway to get statically-linkable binaries on Mac OS X.

Thoughts?