Oct 13, 2012

Qt5 in ArchLinux

If you are a Qt developer and an ArchLinux user, and you want to give a try to the new Qt5 this post is for you. I will show you how to setup the Qt5 development environmet correctly.
First at all we will create a script that points to the Qt5 installation directory. We will install all the Qt5 tools in the /opt/qt5.
export QTDIR=/opt/qt5
export PATH=$QTDIR/bin:$PATH
export PKG_CONFIG_PATH=$QTDIR/lib/pkgconfig:$PKG_CONFIG_PATH
Then create one folder for the Qt5 package, and other for the Qt Creator package and copy this to both folders.
In the Qt5 package folder create a PKGBUILD with the following content:
pkgrealname=qt5
pkgname=$pkgrealname-git
pkgver=20121006
pkgrel=1
groups=('qt5')
pkgdesc="A cross-platform application and UI framework"
arch=('i686' 'x86_64')
url="http://qt-project.org/"
license=('GPL3' 'LGPL')
depends=('libxcb' 'xcb-proto' 'xcb-util' 'xcb-util-image' 'xcb-util-keysyms' 'xcb-util-renderutil' 'xcb-util-wm' 'libedit' 'libwebp')
makedepends=('git' 'perl' 'gperf' 'fontconfig')
options=('!libtool')
provides=('qt5')
conflicts=('qt5')
source=()
md5sums=()

_gitroot="git://gitorious.org/qt/qt5.git"
_gitname=qt5

build() {
    cd "$srcdir"
    . ../qt.profile

    if [ -e "${_gitname}" ]; then
            cd ${_gitname}
            git submodule foreach --recursive "git clean -dfx"
            git pull
            git submodule update --recursive
    else
            git clone ${_gitroot}
            cd ${_gitname}
            perl init-repository
    fi

    ./configure --prefix=/opt/qt5 \
                -opensource \
                --confirm-license \
                -silent \
                -continue

    make -j $(grep -c "^processor" /proc/cpuinfo)
}

package() {
    install -Dm755 "../qt.profile" "${pkgdir}"/etc/profile.d/qt5.sh

    cd "${srcdir}/${_gitname}"

    make INSTALL_ROOT="${pkgdir}" install
}
Then, build and install the package with:
makepkg -si
Be careful, building all Qt5 modules takes around 9 hs to complete, do it early in the morning.
The last step is to create the package for Qt Creator. In the Qt Creator package folder create a PKGBUILD with the following content:
pkgname=qt5creator-git
pkgver=20121009
pkgrel=1
pkgdesc="Qt Creator is a new cross-platform integrated development environment (IDE) tailored to the needs of Qt developers."
arch=('i686' 'x86_64')
url="http://www.qtsoftware.com/products/developer-tools"
license=('LGPL')
depends=('qt5')
makedepends=('git')
provides=('qt5creator-git')
conflicts=('qt5creator-git')
source=()
md5sums=()

_gitroot="git://gitorious.org/qt-creator/qt-creator.git"
_gitname="qt-creator"

build() {
    cd "$srcdir"
    . ../qt.profile

    if [ -e "${_gitname}" ]; then
        cd ${_gitname}
        git pull origin
    else
        git clone ${_gitroot}
        cd ${_gitname}
    fi

    if [ ! -e "build" ]; then
        mkdir build
    fi

    cd build

    /opt/qt5/bin/qmake QT_PRIVATE_HEADERS=/opt/qt5/include ../qtcreator.pro
    make -j $(grep -c "^processor" /proc/cpuinfo)
}

package() {
    cd "${srcdir}/${_gitname}/build"

    make INSTALL_ROOT="${pkgdir}/opt/qt5" install
}
Then, build and install the package with:
makepkg -si
That's all. It's easy, no?

Useful links

3 comments:

  1. WAW vaya curro que te has metido. ;-). Ayer regresé a Arch y vaya sorpresa Qt5 en AUR :-) A ver si pronto está sin tener que compilar, jejeje.


    ArcNexus.

    ReplyDelete
    Replies
    1. Y no me quedo otra opción :P, en el momento que hice el tutorial los paquetes de AUR estaban desactualizados y faltaban un montón de módulos, y yo quería probar Qt5 full, full. Ahora por suerte ya actualizaron los paquetes :)
      Imagino que, ahora que acaba de salir Qt5, tardarán 1 o 2 meses en meterlo extra, pero seguro que lo tenemos antes de KDE 5.

      Delete
  2. viste mi mail sobre Qmysql. Me tiene desesperado. ¿pudiste compilarlo para Arch y Qt5?

    ReplyDelete