Archive

Archive for the ‘Nokia’ Category

Building Qt Static (and Dynamic) and Making it Small with GCC, Microsoft Visual Studio, and the Intel Compiler

October 11th, 2009 64 comments

Qt can easily be made into a smaller library than the default install provides.

This article will show you how to build Qt, the popular C++ framework from Nokia, so that it is both small and, if you prefer, available for static linking. Your Qt applications will be smaller, possibly faster, and can be distributable as a single executable.

Also answered: How small can Intel’s C++ compiler make a large library? How does Microsoft fare? Three compilers (settings tuned for small file output) and their resulting code size is compared.

Read more…

How to statically link Qt 4

September 4th, 2009 23 comments

Make your entire Qt application work entirely from a single file.


qtlogoI was downloading Ubuntu Netbook Remix for my EeePC 900A and found that it’s installer is not a CD image, but a raw image meant to be written to a USB FLASH drive. After downloading their handy image writer, I found that this simple utility came with quite a few support files, including a surprising 13.5MB of .dlls.

This image writer tool was written usingĀ Nokia’s Qt software, which allows easy development and distribution for all the major platforms from a single C++ source base. This program was compiled in the same way most Windows software is today — with “dynamic linking”, requiring the Qt libraries, among others, be shipped with the program as separate files.

This is fine for large software projects, but it’s a little cumbersome for small tools like this one. Many programs can be distributed such that all necessary files are built into the executable in a process called static linking. Sometimes it is nice to be able to download just the program itself and not have to worry about making sure various DLLs are included (though setting up an installer largely eliminates this problem).

Static linking has its advantages and disadvantages, but when not done, running a program unaccompanied by even one support file will result in a cryptic error for the user:

missing_dll

These 4 steps are all you need to make your entire project result in a single, easy-to-distribute .EXE file:

  1. Complete your Qt project using normal debug libraries.
  2. Compile the Qt libraries for static linking (needs to be done only once).
  3. Add the necessary lines of code to include any Qt plugins you may need.
  4. Compile your release version with the static libraries.

Read more…

Categories: Nokia, Open source, Qt Tags: