Category Archives: osx

Installing Harbour, Qt and hbQt on osx

Now that we have a working osx Harbour setup, it is time to add other pieces. My goal is to port a software that runs on Windows under hbQt to Mac (and linux).

So, as the first step, I install the brew package manager, that will handle the setup of external software for me.

To install brew it is necessary to run a script that is downloaded from the web. I report it here but PLEASE do check on its website (http://brew.sh/) it if it is still valid when you will work on it.

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The script will ask for confirmation and for sudo password.

When ready, we can install Qt5.

brew install qt5
brew linkapps qt5

As for today, it will install Qt 5.6.1. With the second line Qt5 bundled applications are installed in Launchpad.

It’s time to download and compile hbQt, but before I want to update my env setup and I do as usual with a script file set_harbour561.sh:

PATH=/usr/local/opt/qt5/bin/:~/harbour/bin/darwin/clang:$PATH
export QT_PLUGIN_PATH=/usr/local/opt/qt5/plugins/
export HB_WITH_QT=/usr/local/opt/qt5/include/
## rem HB_QT_MAJOR_VER can probably become deprecated in next
## rem Harbour/qtcontribs releases.
export HB_QT_MAJOR_VER=5

and I update the env variables with
. set_harbour561.sh

and then I checkout the sources

cd /harbour
svn checkout http://svn.code.sf.net/p/qtcontribs/code/trunk addons

Before compiling hbQt we need to compile a contrib of Harbour, since it depends on Qt and some hbQt programs depend on it. So compile the contribs:

cd <path>/harbour/contribs
make

Then move to the addons directory:

cd <path>/harbour/addons

We need to modify qtcontribs.hbp, since some Qt modules are not available on osx. So add a # in front of the line of:
hbqtdeclarative.hbp
and
hbqt/qtwebkit/hbqtwebkit.hbp

and finally build hbQt:

hbmk2 -jobs=4 qtcontribs.hbp

We are now ready to start hbide and hbdbu programs but you need to access osx gui to be able to use them. Both work as they should but during my tests I found some discrepancies about fonts, layout and GUI: Qt does its best to adapt one codebase to the GUI peculiarities of each GUI but sometimes the result is not perfect and one form dialog that is perfect on windows can have problems on osx.

Will see in another post.

Installing Harbour on osx

In this blog post I will describe how to install basic Harbour on mac osx. It is a really basic installation but it is also fully functional. In the next blog post I will describe how to install Qt and hbQt to create software that can run on Windows, linux and osx.

From your osx gui, install XCode from the App Store. I then used ssh to connect from another server or you can open a terminal window on osx.

First of all we need to accept the XCode license, and we can do this just by invoking one executable.

sudo git

Follow the on-screen instructions to confirm the license.

As usual, I will run Harbour from a directory and I won’t install it system-wide: with this setup I can have multiple different versions available. I will clone the repository with git in order to receive upstream commits.

git clone https://github.com/harbour/core.git harbour
Cloning into 'harbour'...
remote: Counting objects: 275833, done.
remote: Compressing objects: 100% (76/76), done.
remote: Total 275833 (delta 13), reused 3 (delta 3), pack-reused 275754
Receiving objects: 100% (275833/275833), 116.30 MiB | 297.00 KiB/s, done.
Resolving deltas: 100% (216982/216982), done.
Checking connectivity... done.

cd harbour
make -j 4

On my mac mini end-2015 it took less than 2 minutes to complete. I then run

bin/darwin/clang/hbtest

Harbour Regression Test Suite
Copyright (c) 1999-2016, Viktor Szakats

http://harbour-project.org/

---------------------------------------------------------------------------
      Version: Harbour 3.2.0dev (r1606292102)
     Compiler: LLVM/Clang C 7.3 (clang-703.0.31) (64-bit)
           OS: Darwin 15.5.0 x86_64
   Date, Time: 2016-07-01 17:25:22
Shortcut opt.: On
     Switches:
===========================================================================
R No.  Line            TestCall()                               -> Result                                                                                | Expected
---------------------------------------------------------------------------
!  613 MAIN_HVMA(368)  saArray[ 1000 ]
       Result: "E 2 BASE 1132 Bound error (array access) OS:0 #:0 A:2:A:{.[1].};N:1000 "
     Expected: "E 2 BASE 1132 Bound error (array access) OS:0 #:0 "
!  614 MAIN_HVMA(369)  saArray[ 1000 ] := 1
       Result: "E 2 BASE 1133 Bound error (array assign) OS:0 #:0 A:1:N:1000 "
     Expected: "E 2 BASE 1133 Bound error (array assign) OS:0 #:0 "
!  743 MAIN_HVMA(541)  RTSTR( 00000500000000000000 )
       Result: " 16  500000000000000"
     Expected: " 21       500000000000000"
!  744 MAIN_HVMA(542)  RTSTR( 0500000000000000 )
       Result: " 16  500000000000000"
     Expected: " 17   500000000000000"
! 1088 MAIN_MATH(354)  Str( 1234567890 * 1234567890 )
       Result: " 1524157875019052100"
     Expected: " 1524157875019052000"
! 2894 MAIN_ARRAY(158) ASize( NIL )
       Result: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:U:NIL "
     Expected: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 "
! 2895 MAIN_ARRAY(159) ASize( {} )
       Result: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:A:{.[0].} "
     Expected: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 "
! 2896 MAIN_ARRAY(160) ASize( ErrorNew() )
       Result: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:1:O:ERROR Object "
     Expected: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 "
! 2897 MAIN_ARRAY(169) ASize( NIL, 0 )
       Result: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:0 "
     Expected: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 "
! 2898 MAIN_ARRAY(170) ASize( NIL, 1 )
       Result: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:1 "
     Expected: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 "
! 2899 MAIN_ARRAY(171) ASize( NIL, -1 )
       Result: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 A:2:U:NIL;N:-1 "
     Expected: "E 1 BASE 2023 Argument error (ASIZE) OS:0 #:0 "
! 2922 MAIN_ARRAY(213) Array( 1, 0, -10 )
       Result: "E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 A:3:N:1;N:0;N:-10 "
     Expected: "E 2 BASE 1131 Bound error (array dimension) OS:0 #:0 "
! 3061 MAIN_ARRAY(396) TAEVSM()
       Result: "N10N 9N 8N 7N 6         5"
     Expected: "N10N 9N 8N 7N 6N 5N 4N 3N 2N 1         0"
! 3062 MAIN_ARRAY(397) TASOSM1()
       Result: "NN 5NN 4         3{ 2, 1, 3 }"
     Expected: "NN 5NN 4NN 3NN 2NN 1NN 0NN 0NN 0NN 0NN 0NN 0NN 0         0{  }"
! 3063 MAIN_ARRAY(398) TASOSM2()
       Result: "NN 5NN 4         3{ 2, 1, 3 }"
     Expected: "NN 5NN 4NN 3NN 2NN 1NN 0NN 0NN 0NN 0NN 0         0{  }"
! 3183 MAIN_MISC(87)   Set( 40  )
       Result: 0
     Expected: NIL
! 3192 MAIN_MISC(97)   Set( 40 , -1 )
       Result: 0
     Expected: NIL
===========================================================================
Test calls passed:       4757 ( 99.64 % )
Test calls failed:         17 ( 0.36 % )
                   ----------
            Total:       4774 ( Time elapsed: 0.02 seconds )

WARNING ! Failures detected

to test that everything is fine. And of course it is. Otherwise it won’t complete Harbour build.

Now to complete the installation, I create a script in the user root directory that sets the enviromental variables to the path where I compiled Harbour.


PATH=$PATH:~/harbour/bin/darwin/clang

And now I can login, set the environment and use harbour as needed:

. set_harbour.sh
harbour -build
Harbour 3.2.0dev (r1606292102)
Copyright (c) 1999-2016, http://harbour-project.org/

Harbour Build Info
---------------------------
Version: Harbour 3.2.0dev (r1606292102)
Compiler: LLVM/Clang C 7.3 (clang-703.0.31) (64-bit)
Platform: Darwin 15.5.0 x86_64
PCode version: 0.3
ChangeLog last entry: 2016-06-29 23:02 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
ChangeLog ID: f8ec6e2c46068d3f1759c4d75a8f982fc391fb9e
Built on: Jul  1 2016 17:21:51
Build options: (Clipper 5.3b) (Clipper 5.x undoc)
---------------------------