HOW TO BUILD AND INSTALL HARBOUR FROM SOURCE AND CROSS COMPILE HARBOUR
FOR WIN ON LINUX
=======================================================================================

*----------------------------------------
( Tested on Ubuntu 9.04 and Ubuntu 9.10 )
*----------------------------------------

To get main reference please read the INSTALL file under the harbour
source directory

You need to be connected to the Net.

First please  enable the "universe" repositories from menu System
→ Administration → Software Sources and confirm repositorie
reload
Please install these deb packages... so you have almost all packages to
compile contrib libraries and related stuffs

Please open a terminal window Applications → Accessories →
Terminal and type or copy and paste (one row a time then press <enter>)

sudo apt-get update

When you use "sudo" the system ask you for a password, please typein
your user password: you will not see any feedback (i.e terminal chars)
when you type your password, so type the password, then press enter;

sudo apt-get install wget cvs rcs build-essential ncurses-dev
libslang2-dev tk8.3-dev unixodbc-dev subversion libncurses-dev
libx11-dev libgpm-dev libcurl4-openssl-dev firebird2.1-dev
libfreeimage-dev libgd2-xpm-dev libmysqlclient15-dev libpq-dev
libqt4-dev liballegro4.2-dev libsqlite3-dev wine dosemu-freedos mingw32

Then update from svn Harbour

1) - Please open a terminal window Applications &#8594; Accessories
&#8594; Terminal
2) - Please check the requested packages are installed see above;
3) - Type the commands rows below you can also do a copy and paste of the
row, please copy and paste a row a time then press enter;

mkdir $HOME/src
cd $HOME/src
svn co
https://harbour-project.svn.sourceforge.net/svnroot/harbour-project/trunk/harbour
harbour
cd $HOME/src/harbour
export HB_BIN_INSTALL=/usr/bin
export HB_INSTALL_PREFIX=/usr/bin
export HB_LIB_INSTALL=/usr/lib
export HB_INC_INSTALL=/usr/include
make
sudo -E make install

When you use "sudo" the system ask you for a password, please typein
your user password: you will not see any feedback (i.e terminal chars)
when you type your password, so type the password, then press enter;

to verify your build date of harbour, type:
harbour -build

to generate Harbour for Win

cd $HOME/src/harbour/; make HB_PLATFORM=win

export HB_INSTALL_PREFIX=/tmp/hbwin; make install HB_PLATFORM=win

if you want install hbwin in a different directory than /tmp/hbwin with
more stricted directory permissions... you must use sudo to install it:

export HB_INSTALL_PREFIX=/usr/bin/hbwin; sudo -E make install
HB_PLATFORM=win


***********************************
Tip: if you want to automate the update and compile from svn please put
this command into a file for example: MBaggharbour2_svn so type
mkdir $HOME/src
cd $HOME/src

gedit MBaggharbour_svn

Copy and paste the contents below into the file:


#!/bin/bash
clear
echo "----------------------------------------------------------------"
echo "Please wait connecting to svn server to fetch Harbour updates..."
echo "----------------------------------------------------------------"
cd $HOME/src
svn co
https://harbour-project.svn.sourceforge.net/svnroot/harbour-project/trunk/harbour
harbour

sleep 3

cd $HOME/src/harbour
export HB_BIN_INSTALL=/usr/bin
export HB_INSTALL_PREFIX=/usr/bin
export HB_LIB_INSTALL=/usr/lib
export HB_INC_INSTALL=/usr/include
#export HB_CONTRIBLIBS="hbqt hbpgsql hbhpdf rddsql hbsqlit3 hbodbc
gtqtc"

#hbverfix

r='n'

echo "Do you want to run a make clean before to compile sources [Ny]
Please answer in 4 sec"
read -t 4 r


if [[ $r == 'Y' || $r == 'y' ]]; then
        make clean; make; sudo -E make install
else
        make; sudo -E make install
fi

cw='n'
echo "Do you want to compile Harbour for Win [Ny] Please answer in 30
sec or press enter"
read -t 30 cw

if [[ $cw == 'Y' || $cw == 'y' ]]; then
        unset cw
        cd $HOME/harbour
        unset HB_BIN_INSTALL
        unset HB_INSTALL_PREFIX
        unset HB_LIB_INSTALL
        unset HB_INC_INSTALL
        old_path=$PATH
        export PATH=/tmp/hbwin/bin:$PATH
        make HB_PLATFORM=win
        export HB_INSTALL_PREFIX=/tmp/hbwin
        make install HB_PLATFORM=win
        PATH=$old_path
fi




--------------------------
Please save and exit from gedit editor then please give to this script
the execute permission, type:
chmod 700 MBaggharbour_svn

Then to run it...

cd $HOME/src
./MBaggharbour_svn


then inside /tmp/hbwin/bin you will find hbw* scripts which you can use
to build windows binaries.


Point this envvar to the directory where native Harbour executables for
your host platform can be found:
HB_BIN_COMPILE=<HARBOUR_NATIVE_BUILD_DIR>\bin
If you leave this value empty, the make system will try to autodetect it,
so in practice all you have to do is to create a native build first (no
'install' required), then create the cross-build. If you set this value
manually, it may be useful to know that only harbour, hbpp and hbmk2
executables are required for a cross-build process to succeed.

*********************************************************
Howto compile the harbour/contrib/hbnetio/test/netiotst
**********************************************************

# cd $NOME/src/harbour/contrib/hbnetio/tests

Just add this directory to you PATH, i.e.:

# export PATH=/tmp/hbwin/bin:$PATH

to your *nix PATH and then:

# hbwmk -static -n -w -es2 -mt -gtwin netiotst

To check the file generated

# file netiotst.exe
netiotst.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit

To run the test...

wine ./netiotst.exe



********************************************************************
> When all is compiled fine, i must run the complied file inside dosemu... 
> right ?

No. DOSEMU is for pure DOS emulation. Win32 programs should be executed
using WINE, i.e.
wine ./netiotst.exe
********************************************************************

so

wine ./netiotst.exe

to debug something

WINEDEBUG=relay; wine ./netiotst.exe

or double click using nautilus on the generate exe file

we can test if the exe is running by typing
ps -el | grep -i netiotst.exe

You can also register WINE in binfmt and then you can execute windows
programs just like native linux ones if they only have execute attribute
(x).


Then please read this

http://lists.harbour-project.org/pipermail/harbour/2009-September/024351.html
http://lists.harbour-project.org/pipermail/harbour/2009-September/024352.html


*********************************************
To test netio with a server and client app
*********************************************

mkdir $HOME/hb_testio
mkdir $HOME/hb_testio/data
cd $HOME/hb_testio


We can create 2 prg files... the netio_client.prg and the netio_server.prg

So we can use gedit to create the netio_client.prg file

gedit netio_client.prg



-- Then copy and paste the contents below:

#define DBNAME    "net:data/_tst_"

request DBFCDX

proc main( cServer, cPort )
   local pSockSrv

   set exclusive off
   rddSetDefault( "DBFCDX" )
?"start netio app client applications..."
   if empty( cServer )
      cServer := '127.0.0.1'
   endif
   if empty( cPort )
      cPort := '63000'
   endif

   ?
   ? "NETIO_CONNECT():", cServer, int( val( cPort ) ), netio_connect(
cServer, int( val( cPort ) ) )
   ?

   createdb( DBNAME )
   testdb( DBNAME )
   wait

   return

proc createdb( cName )
   local n
if !dbExists( DBNAME )
   dbCreate( cName, {{"F1", "C", 20, 0},;
                     {"F2", "M",  4, 0},;
                     {"F3", "N", 10, 2},;
                     {"F4", "T",  8, 0}} )
   ? "create neterr:", neterr(), hb_osError()
   use (cName)
   ? "use neterr:", neterr(), hb_osError()
   while lastrec() < 100
      dbAppend()
      n := recno() - 1
      field->F1 := chr( n % 26 + asc( "A" ) ) + " " + time()
      field->F2 := field->F1
      field->F3 := n / 100
      field->F4 := hb_dateTime()
   enddo
   index on field->F1 tag T1
   index on field->F3 tag T3
   index on field->F4 tag T4
   close
   ?
else
   ? DBNAME, 'Already exists'
endif
return

proc testdb( cName )
   local i, j
   ?
   ? 'using:',time()
   use (cName)
   ? "used:", time(), used()
   ? "nterr:", neterr()
   ? "alias:", alias()
   ? "lastrec:", lastrec()
   ? "ordCount:", ordCount()
   for i:=1 to ordCount()
      ordSetFocus( i )
      ? i, "name:", ordName(), "key:", ordKey(), "keycount:",
ordKeyCount()
   next
   ordSetFocus( 1 )
   dbgotop()
   while !eof()
      if ! field->F1 == field->F2
         ? "error at record:", recno()
         ? "  ! '" + field->F1 + "' == '" + field->F2 + "'"
      endif
      dbSkip()
   enddo
   i := row()
   j := col()
   dbgotop()

   ? 'locking:',time()
   ? 'locked:', rlock(), time()

   wait

   browse()
   setpos( i, j )
   close

   return




- Save and exit




-- Then we must create the netio_server.prg

gedit netio_server.prg


-- Then copy and paste the contents below:



proc main( cServer, cPort )
   local pListenSocket

   if empty( cPort )
      cPort := '63000'
   endif
//   if empty( cServer )
//      cServer := '127.0.0.1'
//   endif

   pListenSocket := netio_mtserver( val( cPort ), cServer )
   if empty( pListenSocket )
      ? "Cannot start server. press a key to exit..."
      inkey(0)
   else
      wait "Press any key to stop NETIO server."
      netio_serverstop( pListenSocket )
      pListenSocket := NIL
   endif
   return



- Save and exit

Then we must compile them...

export PATH=/tmp/hbwin/bin:$PATH; hbwmk -static -n -w -es2 -gtwin
netio_client.prg; hbwmk -static -n -w -es2 -gtwin -mt netio_server.prg


Then to test the netio apps

A) If we are on the same pc we must open two terminal (1 e 2) on terminal
(1) type:
wine ./netio_server.exe

on the terminal 2 type:
wine ./netio_client.exe

B) if we have two pc on the net (A and B) on pc A open a terminal and
type:

ifconfig

to get the ip number, then we can start the server

wine ./netio_server.exe

on the pc B we must copy the netio_client.exe and run it

wine ./netio_client.exe ip_of_pc_where_netio_server_is_running



****************************************************************************************************
Przemek note...
****************************************************************************************************
NETIO server application has to be linked with MT HVM version.
Please use -mt hbwmk switch to compile server.

> > give me the wine app started window with the message it cannot start 
> > server...
> > Can you test my app in your enviroment...
> > in attach the hb_testio.tar.gz
It works if you compile netioserver.prg with -mt switch.
I tested Windows and Linux binaries.
BTW for normal usage I suggest to always use native binaries.
If you want to run server on Linux machine then create native
Linux netio server binaries. And of course native client binaries.
Of course you can connect to the one server from different stations
working with WIN, DOS, OS2 or different *nixes.

And remove from netioserver.prg this code:

   if empty( cServer )
      cServer := '127.0.0.1'
   endif

it reduces connections to 127.0.0.1 only so such server cannot be accessed
remotely. Use empty value or 0.0.0.0 if you want to give access from
different interfaces without any limitation.
****************************************************************************************************
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to