Compiling Harbour for Qt from GIT

This is a step-by-step guide to install Harbour and QtContribs from source code.

Our goal is to create a self-contained setup that can be used on a development workstation alongside different versions of Harbour and Qt.

In this setup, Harbour is never “installed” but just compiled with proper settings and only environment variables are set.

Since the nigthly build of Harbour uses an old version of the compiler not compatible with recent Qt, it is necessary to build Harbour ourselves.

If we want to be able to easily receive the updates from Harbour and QtContribs projects we should use git and svn. Otherwise you can simply download the source zip files and unpack them.
I suggest to use git and svn to download source code.

So proceed to install git and svn (TortoiseSVN, from sourceforge).

Download and install Qt 5.2

Go to http://qt-project.org/downloads and download “Qt 5.2.1 for Android (Windows 32-bit, 1.1GB)”.

This is the version available on april 2, 2014. I use the android version since this is a system-wide installation and I will use it for Android development.

Install it using default dir (c:\qt\qt5.2.1). In “Select Components” open Tools and select MinGW 4.8: this will install the compiler used to build Qt and it is the compiler we will use to compile Harbour to have maximum compatibility. In the past I also installed Qt source code but I don’t do anymore…

Proceed with installation but do not launch Qt Creator at the end since we don’t need it.

Build Harbour

I put all these source code in a directory called cvs in c:
In this directory I put all the configuration files (see below) and the source dirs.

From command prompt, go to c:\cvs directory

c:
cd \cvs
git clone https://github.com/harbour/core.git harbour

It takes some time.
Please note that we specify harbour as last parameter in the git command: it will create a clone of the repository in a directory called harbour. You should have now a c:\cvs\harbour\README.md file.

You can download the source code as a zip file clicking on the button on the right ( https://github.com/harbour/core.git ), unzipping and move/rename the directories to have the README.md file in the position shown above.

If you want to create multiple parallel versions of Harbour, for example one for production code and one to test new features, you can clone Harbour changing the last paramenter.

Now it is time to set the environment. I never do this in a system-wide setting but use a batch file that I call after the Qt version or the specific use of that setup.
This file sets the environment variables needed to compile and use Harbour and I called it set_qt521.bat.

PATH=c:\qt\qt5.2.1\tools\mingw48_32\bin;C:\qt\qt5.2.1\5.2.1\mingw48_32\bin;C:\cvs\harbour\bin\win\mingw;c:\bin;%PATH%;
SET QT_PLUGIN_PATH=C:\Qt\qt5.2.1\5.2.1\mingw48_32\plugins
SET HB_WITH_QT=C:\qt\qt5.2.1\5.2.1\mingw48_32\include
rem HB_QT_MAJOR_VER can probably become deprecated in next
rem Harbour/qtcontribs releases.
SET HB_QT_MAJOR_VER=5

Let’s examine the dirs of PATH:

  • c:\qt\qt5.2.1\tools\mingw48_32\bin
    c/c++ mingw compiler included in Qt
  • C:\qt\qt5.2.1\5.2.1\mingw48_32\bin
    all the tools of Qt
  • C:\cvs\harbour\bin\win\mingw
    This dir doesn’t exist yet but Harbour build process will copy here all the Harbour executable
  • c:\bin
    is a dir where I put all the tools I use during code development (diffs tools, grep…)
  • QT_PLUGIN_PATH is needed to run programs that use Qt.
    HB_WITH_QT specifies at build time which version of Qt we want to use
    HB_QT_MAJOR_VER specifies which Qt major version we are using. It may be removed in the future

    It is now easy to create copies of this file and adapt the dirs to use other Qt versions or other Harbour dirs.

    Now build Harbour.

    set_qt521.bat
    cd harbour
    win-make clean
    win-make
    

    Harbour will be compiled. It is normal that near the end there are some warnings/errors during compilation of contribs: the build process checks for the presence of supported libraries and skip build if they are not present.

    When compilation is terminated we can check:

    C:\cvs\harbour>harbour --version
    Harbour 3.2.0dev (r1404111536)
    Copyright (c) 1999-2014, http://harbour-project.org/
    

    Compile QtContribs

    With TortoiseSVN do a checkout of the repository, using data as per the following screenshot. If you are behind a firewall, use http instead of svn in the url (http://svn….)
    (To help with copy&paste: svn://svn.code.sf.net/p/qtcontribs/code/trunk C:\cvs\harbour\addons )
    svn-addons
    Click ok and wait for the checkout.

    You now have this file:
    c:\cvs\harbour\addons\qtcontribs.hbp

    You can download the source file zip from Sourceforge, uncompress it, rename the directory and move it to have the file in the position shown above.

    NOTE OF 17 April 2014: Pritpal added some new features but there are some problems compiling them. So please edit qtcontribs.hbp and rem these lines:

    #### hbqt/qtpositioning/hbqtpositioning.hbp
    #### hbqt/qtwebsockets/hbqtwebsockets.hbp
    #### hbqt/qtbluetooth/hbqtbluetooth.hbp
    

    Now start compilation:

    cd addons
    hbmk2 qtcontribs.hbp
    

    When completed you can check running hbide.

    hbide
    

    Opening menu Help -> About Harbour IDE you should get something like this:
    hbide-about

    What’s next

    From now on, when you need to use this version of Harbour with this version of Qt you can run set_qt521.bat and compile your programs. Please note that you can compile programs that don’t use Qt !

    2 thoughts on “Compiling Harbour for Qt from GIT

    1. Luigi Ferraris

      Thanks Francesco for this and other useful informations.
      Long Life to Xbase language.
      Best regards

      Reply
    2. Luigi Grella

      Thanks. currently I am working on a program that works fine in clipper (10 months of use) and I am trying to add GUI using Minigui.
      When I have finished I will try and create a marriage of my clipper program with QT

      Reply

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>