Tuesday, April 15, 2014

[Qt] Compiling Qt5.2.1 on Windows 8/VS 2013

Qt5. It's a miasma. It's a beast for me. It's something mysterious. I don't know if I should love Qt5 or hate it.
And I think that summarizes my thoughts about Qt5.

I first stumbled across the fifth iteration when some functionality in the product I was working on couldn't be done in existing Qt version (4.5.3 btw). So after looking around for the Oracle, I came to know that the functionality can be achieved by moving to Qt5.

Now our development platform (WinXP/CentOS 5.3/ Qt 4.5.3) was getting a bit too old. And it was all quite buggy to boot. So we decided to embark on the adventure of upgrading the base. Took us two months to upgrade the Linux side to CentOS6.3/ Qt5.0.1 and port the product to new Qt. But after that other high priority work kept us busy and we never got to get the Windows side up to speed.

But then came the fateful day two weeks ago when our IT Manager announced the upgradation of all our faithful old XP systems into Windows 8. And then as it happens, people go ahead and nobody asks the actual user, our PC's were upgraded to Win 8.

Now think, in the old workflow, we would develop on Win XP. And then do unit testing for both Windows and Linux. Usually Linux would need a few tweaks and that would end the development. We didn't have any development tools on Linux. We stuck to the faithful Visual Studio 2005. And it did work.

And now suddenly we are handed Windows 8 and the polished and shiny Visual Studio 2013. But nobody bothered to ask whether this combo was even desirable. So it came to our notice that we can't develop anything because...1. We don't have a compatible Qt version, 2. Visual Studio 2013 needs vsxprojects and the conversion from 2005 vcproj files somehow doesn't work at all. 3. We have by now turned into spittering globs of bio-mechanical matter who are so useless that we should be flushed into space if we are to be in a spaceship!!!

Thankfully the genius in us found a solution and set up virtual machines of XP with all our poor stuff and so we resumed work. But the shiny new windows 8 was still sitting there with next to useless Visual Studio 2013. And we had to do something about it. So I cleared some time (about a week) in my schedule (mind you it's not much crowded anyway!!! :D ) and started on this journey.

1. Prerequisites:
Building full Qt5 (with QtWebkit ) on Windows needs a lot of stuff. And sadly we needed QtWebkit for a few webviews that we have been using in our product. So the requirements:
[Qt pre-requisites]
DirectX SDK - needed for OPENGL/ANGLE stuff.
Windows SDK - Better to have it, But Windows SDK 8 failed to install. The turd would hang on one Cab file thet it couldn't download and it would quit. Sucks!

[Qt webkit pre-requisites]
Perl - install latest Active Perl. Add path to binary to Path Env Variable.
Python - install latest Python. Add path to Python binary to Path Env Variable.
Ruby - install latest Ruby too. Add path to Ruby binary to Path Env Variable.
Cygwin with make utility - Needed to build icu. Add path to cygwin bin to Path Env Variable.
ICU - Needed by QtWebkit. If you can get a binary icu lib well and good. But there was nothing for use with Visual Studio 2013.
Flex-Bison - Install flex-bison package. Add path to Path Env Variabl. Rename Win-flex and Win-bison to flex and bison respectively. Otherwise webkit builder complains about missing flex and bison.
gnuwin32 - Install the gnuwin32 package for gperf tool. Also add path to gperf binary to Path Env Variable.

2. Building:

A. Build ICU:

Following link includes proper instructions for building ICU for use with Qt:

B. Build Qt:
For building Qt, I have prepared a script:
:: BuildQt5
:: Run this from VS command prompt
set QTSRC=D:\QtSource\qtsrc-5.2.1
set QTBUILD=D:\QtSource\qt-5.2.1_build
set QMAKESPEC=win32-msvc2013
set PATH=%PATH%;C:\icu\dist\lib
set INCLUDE=%INCLUDE%;C:\icu\dist\include
set LIB=%LIB%;C:\icu\dist\lib
%QTSRC%\configure -developer-build -opensource -nomake examples -nomake tests -plugin-sql-psql -I "C:\Program Files (x86)\PostgreSQL\9.1\include" -L "C:\Program Files (x86)\PostgreSQL\9.1\lib" -l libpq -debug-and-release -mp -confirm-license -prefix c:\Qt-5.2.1
:: nmake
:: nmake install
cd ..
I run this in three phases; first keeping the configure line and let it configure Qt. Once I have all required options properly configured, I run nmake and later nmake install phases.
I am adding PostgreSQL database as plugin. Depending on your use you can add other databases like mySQL too.

Getting this configuration right was a major step. Then Qt normally takes about 3-4 hrs depending on your system. Mind you, this is whole Qt building. If you know exactly which modules you need, then you can just build those modules too.

Once Qt is built, I compile a small program like Hello World and confirm it working.

C. Build QtWebkit:
Previously QtWebkit would build along with Qt itself. But in Qt5 the developers have removed QtWebkit module as well as the switches or selecting / un-selecting it. The dependencies are ICU, Perl, Ruby, Python, gperf.

To build QtWebkit, first you need to build Webkit.

cd to %QTSOURCE%/qtwebkit
Ensure ICU library details are provided in environment:

set PATH=%PATH%;C:\icu\dist\lib
set INCLUDE=%INCLUDE%;C:\icu\dist\include
set LIB=%LIB%;C:\icu\dist\lib

Next, set path to sqlite sources:
SET SQLITE3SRCDIR=D:\QtSource\qtsrc521\qtbase\src\3rdparty\sqlite

And then, run the perl script to build webkit:
perl Tools\Scripts\build-webkit --qt --debug --no-webkit2

Then build QtWebkit:
qmake WebKit.pro

And if everything works out
nmake install

This will install QtWebkit module.

E. System configuration:
To use this Qt you need to do couple of settings:
1. Add Qt bin and lib paths to Path environment variable.
2. Create a new system environment variable QTDIR and assign it the path of Qt directory.

F. Build Qt Creator; Qwt etc
For all these the steps are simple:
cd to Source dir
qmake project file
nmake install

Or if you want to go via visual studio then
qmake -tp vc "project file"

This would generate the required vcxproj file which you can open with VS2013.

3. Test installed Qt.
Go to Qt sources and try out various examples provided in the modules. See if they build without any issues. This should give you confidence that Qt is built correctly and there's no problem anywhere.

Note: There are changes around with respect to integration with COM components and so if your project is using some COM components then you will get some errors like

C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atliface.h
(80) : warning C4091: '' : ignored on left of 'interface' when no variable is de
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\ATLMFC\INCLUDE\atliface.h
(86) : error C2146: syntax error : missing ';' before identifier 'IAxWinAmbientD

In this case adding following

to pro file may help. And you may also need to revise the include order for the files.

Saturday, April 12, 2014

[Thoughts] Senn HD 439 vs Panasonic ht515

Songs tested against on Samsung Omnia W
Bezuban from abcd
gangnam style
Sun raha hain - female  from Aashiqui 2
Saajna from I, me aur main
Teri jhuki nazar - murder 3

Let me call Panasonic p and sennheiser s.
P sounds good, but not excellent. It had reasonable amount of bass and the soundstage is good. The sound is on the warmer side. And if you haven't heard s then you might think p is great. Yeah its that good.
Now when you plug in s, the first thing you notice id that the highs are much more perfected on s. The bells and thrums of guitar sound fuller. The bass gets punchier. The sound experience becomes better by about 35%.
And that's that straight forward difference you hear. P are not bad headphones. In fact these used to retail at about 30% price of s's. And so these are excellent value for money. The pair I have is about five years old and even though it looks totally plasticky it has held through rough use. The cable is strong and doesn't have slightest cable noise. S's cable is thin and has slight cable noise.

Update: After more than 50 hrs of burning in, the soundstage has opened much more. The frequency response also seems slight different - consistent with the opened soundstage.

Thursday, April 10, 2014

[Qt] Compiling ICU with MSVC (Microsoft Visual Studio)

Link to original article: http://qt-project.org/wiki/Compiling-ICU-with-MSVC

Text highlighted and notes added

Compiling ICU with MSVC (Microsoft Visual Studio)


Qt 5 / QtWebkit requires ICU.


Pre-built packages


The ICU Project site [site.icu-project.org] provides pre-built packages for MSVC 2010, which should work with compilers too. Anyhow, you have to compile your own version if you want to avoid the MSVC 2010 runtime dependency (because you’re using another MSVC version), or want to tailor the ICU configuration.


download.qt-project.org [download.qt-project.org] also hosts packages for MSVC 2012 .


Compiling on your own





How to build


  • Download latest ICU4C source code from http://site.icu-project.org/download (e.g.icu4c-53_1-src.zip), unzip

  • Make sure you’ve e.g. ‘make’ installed for Cygwin

  • Start cmd.exe and put Cygwin in PATH, convert line endings

    1. C:\icu\source> set PATH=C:\cygwin\bin;%PATH%

    2. C:\icu\source> dos2unix *

    3. C:\icu\source> dos2unix -f configure


NOTE: for PostgreSQL plugin I added it to configure as

-I "C:\Program Files (x86)\PostgreSQL\9.1\include" -L "C:\Program Files (x86)\PostgreSQL\9.1\lib" -l libpq

I tried to add icu library in the same way but it seems like these options are directly passed on to the compiler and configure script doesn’t consider them. So we need these set commands.

Check whether you have e.g. the MSVC compiler (cl.exe) in PATH. If not, set it up by calling e.g.


  1. C:\icu\source> "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86


Run configure && build:

  1. C:\icu\source> bash runConfigureICU Cygwin/MSVC --prefix=/cygdrive/c/icu/dist


This will generate a release shared build that you can use in both a debug and release build of Qt.


To link ICU statically (e.g. for a static release build of Qt), you have to append ‘—enable-static —disable-shared’ :

  1. C:\icu\source> bash runConfigureICU  Cygwin/MSVC --prefix=/cygdrive/c/icu/dist --enable-static --disable-shared


To link ICU statically and build it in debug mode (e.g. for a static debug build of Qt), you have to prepend ‘—enable-debug —disable-release’ to the arguments:


  1. C:\icu\source> bash runConfigureICU  --enable-debug --disable-release Cygwin/MSVC --prefix=/cygdrive/c/icu/dist --enable-static --disable-shared


Finally, run make && make install


  1. C:\icu\source> make && make install




Add the include, lib folders to your compilation environment, e.g. for cmd.exe :


  1. C:\icu\source> set PATH=%PATH%;C:\icu\dist\lib

  2. C:\icu\source> set INCLUDE=%INCLUDE%;C:\icu\dist\include

  3. C:\icu\source> set LIB=%LIB%;C:\icu\dist\lib


When you now run Qt’s configure.exe ICU should be detected, and Qt links against the libraries.