It’s surprising how often people seem to ponder how to switch between different Qt/Qtopia versions when they have multiple versions of Qt/Qtopia installed. All what really matters is to have the right qmake in PATH at time. Even if it might not be that hard to write a shell script to do the switch, I decided to praise Debian’s update-alternatives tool a bit. Just look below how easy it is to manage multiple Qt/Qtopia installations with update-alternatives.
I have installed Qt 4.3.2 from Ubuntu repositories to /usr/lib. In addition to that, I have the following hand-compiled installations:
$ ls /usr/local/Trolltech Qt-4.3.4 Qt-4.4.0-beta1 QtopiaCore-4.3.4 QtopiaCore-4.4.0-beta1
Update-alternatives is already aware of the Qt version installed from Ubuntu repositories. To make it also aware of those hand-made compilations we invoke such commands as:
sudo update-alternatives --install /usr/bin/qmake qmake /usr/local/Trolltech/Qt-4.3.4/bin/qmake 30 sudo update-alternatives --install /usr/bin/qmake qmake /usr/local/Trolltech/Qt-4.4.0-beta1/bin/qmake 10 sudo update-alternatives --install /usr/bin/qmake qmake /usr/local/Trolltech/QtopiaCore-4.3.4/bin/qmake 20 sudo update-alternatives --install /usr/bin/qmake qmake /usr/local/Trolltech/QtopiaCore-4.4.0-beta1/bin/qmake 10
Whenever I want to change the Qt/Qtopia version I do:
$ sudo update-alternatives --config qmake There are 5 alternatives which provide `qmake'. Selection Alternative ----------------------------------------------- + 1 /usr/bin/qmake-qt4 * 2 /usr/local/Trolltech/Qt-4.3.4/bin/qmake 3 /usr/local/Trolltech/QtopiaCore-4.3.4/bin/qmake 4 /usr/local/Trolltech/Qt-4.4.0-beta1/bin/qmake 5 /usr/local/Trolltech/QtopiaCore-4.4.0-beta1/bin/qmake Press enter to keep the default[*], or type selection number:
Not very complicated, is it?