Building Qt 4.4 for RHEL 5

As explained here, I wanted to build RPMs for Qt 4.4 for Red Hat Enterprise Linux 5. Compiling from sources was taking way too much time and was not attracting any developer love.

If you want to use Qt 4.4 with RHEL 5, you'll need an updated version of KDevelop ( > 3.4) too. And that requires an updated version of GDB (v6.8). So you'll need to find those RPMs as well.

Building an RPM is apparently a complicated process and you'll find lots of articles online (some very dated). But there's a way to reuse the packaging generated for Fedora. That way, you don't have to mess with source archives, patches and write spec files from scratch.

Getting the source packages

Koji is Fedora Project's build system. You can checkout source packages from http://koji.fedoraproject.org/koji/ and use it to build on RHEL. Cool, huh? But be aware of possible compatibility issues.
Using the search facility of Koji site, I downloaded the following src.rpm files.
qt-4.4.0-11.fc10.src.rpm
kdevelop-3.5.3-1.fc8.src.rpm
gdb-6.8-23.fc9.src.rpm


In Koji, you'll find packages for several Fedora versions. I'll recommend using the lower Fedora versions (which matches the version of software you are looking for, of course), since RHEL is an old (F6 based) distro. Later Fedora versions may use different package versions or install paths and may cause problems with RHEL.

Preparing the build setup

Information on how to do this can be found in all rpm building tutorials. But I'll put it here too ;-)
1. Create an RPM build directory structure

$ cd ~
$ mkdir myrpms
$ cd myrpms
$ mkdir SOURCES SPECS BUILD SRPMS
$ mkdir -p RPMS/i386 RPMS/athlon RPMS/i486 RPMS/i586 RPMS/i686 RPMS/noarch

2. Create a file named .rpmmacros in your home directory with contents:
%_topdir /home/yourusername/myrpms
or whatever to reflect your settings.

Apparently, this says that you can do all that with:
$ mkdir -p ~/myrpms/{BUILD,RPMS,S{OURCE,PEC,RPM}S}
$ echo -e "%_topdir\t$HOME/myrpms" >> ~/.rpmmacros


Installing the source rpm
$ rpm -ivh qt-4.4.0-11.fc10.src.rpm

The source (and patches) will go to the SOURCES directory, SPEC file in SPECS, and rpms after build will go in the RPMS directory.

Building Qt 4.4

The 'spec' file contains the instructions to the rpmbuild command to build the rpm. Open SPECS/qt.spec and see how it looks like. Note the BuildRequires: lines. Those are the packages that you must have inorder to build a package.
Some spec files will have conditional constructs using which they handle multiple build environments. To compile Qt 4.4 on RHEL 5, do this:
$ cd ~/myrpms/SPECS
$ ls qt.spec
$ rpmbuild --define "webkit:1" --define "rhel 5" -bb qt.spec


Most probably the above command will fail with lots of BuildRequires messages. You need to install all those packages before you can continue. You can make use of EPEL and RPMForge repositories to locate packages that are not in the official RHEL repos. The --define stuff is only required for Qt 4.4, and not for KDevelop, gdb etc. (in case you were wondering!).

In some cases (KDevelop, for example), you'll find that the spec file (originally meant for later versions of Fedora) will require packages like kdelibs3-devel, kdesdk3-devel etc. You need to install kdelibs-devel, kdesdk-devel etc. instead and modify the spec file.

Once you've installed the required packages, execute the rpmbuild command again. If all goes well, you'll see the RPM file in RPMS/ directory. For me it's i386. Try installing the rpm on your machine before you start distributing!

Note on KDevelop 3.5.3

You can find this RPM from http://kdevelop.org. This works fine with RHEL 5. But if you want to customize an RHEL install DVD, don't use that package. It has a self-obsoletion problem which will make the installer fail. Building the RPM by yourself is the only safe way.

Packages I've successfully built
Qt 4.4
KDevelop 3.5.3
GDB 6.8
Kst 1.7

Good luck. Build away..

Update: RHEL 5.3 now comes with gdb 6.8.27. Combined with a new kernel, all issues with debugging are now resolved. Hooray!

Comments

  1. Wow this is just what I was looking for almost two days, I need to do a project and this will help me a lot, thanks for the post.

    ReplyDelete
  2. @Generic Cialis
    Thanks..
    I've subsequently compiled Qt 4.5 on RHEl 5. But for that I had to use a different SPEC file than that included in the package for Fedora (Fedora guys seem to separate phonon components out of Qt package). Than Ngo at Fedora helped me with the spec file.

    ReplyDelete

Post a Comment

Popular posts from this blog

Qt - Enabling qDebug messages and Qt Creator

പേര്

Dakhani Degh - Restaurant