How to switch Qt version in Ubuntu
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?
September 2nd, 2008 at 12:56
Oh, and you can use “slaves” to make it a complete switch, including the whole set of Qt tools. For example:
sudo update-alternatives –install /usr/bin/qmake qmake /usr/local/Trolltech/Qt-snapshot/bin/qmake 25 –slave /usr/bin/moc moc /usr/local/Trolltech/Qt-snapshot/bin/moc –slave /usr/bin/uic uic /usr/local/Trolltech/Qt-snapshot/bin/uic –slave /usr/bin/rcc rcc /usr/local/Trolltech/Qt-snapshot/bin/rcc –slave /usr/bin/lrelease lrelease /usr/local/Trolltech/Qt-snapshot/bin/lrelease –slave /usr/bin/lupdate lupdate /usr/local/Trolltech/Qt-snapshot/bin/lupdate –slave /usr/bin/linguist linguist /usr/local/Trolltech/Qt-snapshot/bin/linguist –slave /usr/bin/assistant assistant /usr/local/Trolltech/Qt-snapshot/bin/assistant –slave /usr/bin/designer designer /usr/local/Trolltech/Qt-snapshot/bin/designer
December 21st, 2008 at 16:48
hi ,
Could you tell me how to install Qt-4.3.4 successfully in Ubuntu 8.10
December 21st, 2008 at 22:22
Why 4.3.4? There’s 4.4.3 in Ubuntu Intrepid repos:
sudo apt-get install libqt4-dev qt4-dev-tools qt4-doc
January 28th, 2009 at 00:15
Hi,
another demande how to install qt 4.3.x under ubuntu 8.10. The reason is quiet simple. If i want ot use OpenFoam -> paraFoam (binary package) there must be installed Qt 4.3.x. Doesn’t work with 4.4.x.
Janez
January 28th, 2009 at 09:42
Hi,
I still don’t know why because Qt 4.4 is backwards binary compatible with Qt 4.3. But anyway, then download the Qt 4.3 source package from ftp://ftp.trolltech.com/qt/source and follow the installation instructions http://doc.trolltech.com/4.3/install-x11.html.
PS. Pay attention to the configure script output, after qmake has been compiled. There’s a detailed summary you might want to check out. Enabling some specific feature is only a matter of installing the corresponding development (ie. libxxx-dev) package.
April 9th, 2009 at 15:58
Hi,
Thank you for your post, which solve my problem about qmake version update!
kenez
May 27th, 2009 at 11:07
[...] worked on my ubuntu just fine. follow the qt4.3.4 then i followed this webpage http://jpnurmi.kapsi.fi/blog/2008/03…ion-in-ubuntu/ do this: sudo update-alternatives –install /usr/bin/qmake qmake [...]
August 3rd, 2009 at 16:34
Very useful post! Thanks!
November 12th, 2009 at 17:10
[...] about how to switch Qt version in Ubuntu but you have to install other version of Qt before that: http://jpnurmi.kapsi.fi/blog/2008/03…ion-in-ubuntu/ Follow the point 2.1 Qt to install other versions of Qt and do the switch… Let me know the [...]
June 20th, 2011 at 17:01
[...] Here is a good tutorial show you how to switch Qt version on Ubuntu: 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. [...]