Qt4 from source

I had installed Qt4, Qt3-designer and Qt3-assistant from Ubuntu repos. I had been using Qt3-assistant examples and writing them in PyQt4, whole the document I was referring actually corresponds to Qt3.

Pradeepto was looking at my earlier blog post which had a PyQt4 code and pointed to me that I was rather working with PyQt3/Qt3. He was the one who suggested to make a source install of Qt4, as everything comes with it in one go. So here are the steps..

1. Download the source tar ball from the Qt’s home page which is Trolltech’s Qt Download site.

2. Untar the tar ball where ever you like to have it.

3. Like a typical source installation, with your current working directory pointing to the directory where you extracted the tar ball, run the following after one another in a terminal/console.

$ ./configure # check ./configure --help to know more options like -debug
$ make -j 4 # this may freeze your computer, do it if you have a powerful horse!

4. The ‘make’ command will build Qt4 from source. Generally, we run ‘make install’ also, which will install the built files in appropriate fixed locations. But, this is not mandatory, we can still run Qt4 from where we built it with a few additional things.

5. First, we need to add the files in /bin of Qt4 into the path; likewise the librariries and docs as well. We can sym link the files to existing path such as ‘/usr/bin’. Or else, we can set a few environment variables and proceed with out work. This can be done with a simple shell script, which needs to be executed before we start working with Qt4 everytime.

export QTDIR=/home/joe/qt-4.2.2
export PATH=$PATH:$QTDIR/bin

6. When I openned up qt4-assistant, it showed me an error pop up stating that files were not found at a specific location. So, I had to copy these files to that specific location. I tried sym link but unfortunately it did not work, so I copied them rather.

Destination: /usr/share/qt4/doc/html/    Source: $QTDIR/doc/html/

The above files can either be sym linked (if it works for you) or copied by creating the destination directory. Now, open up the qt4-assistant and you should be able to see the contents.

7. I have a problem, rather a bug, which I suspect to be specific to Ubuntu Edgy. When I export the above paths and open up qt4-assistant or qt4-designer, as well sym link both to ‘/usr/bin’ or anywhere, the fonts on the window is not rendered properly. But, when I execute them from the place where I built them, which happens to be under ‘home’ directory, they get rendered properly. This is quite odd and till now I haven’t got a reason and solution to this.

This is just an account of my experience of installing Qt4 from source. But it was rather a very good experience. Installing from source is always fun, except when you get caught in a maze of dependencies 😀


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s