Go home
Go back to other tutorials

How to build HARBOUR to compile PRG for Android

in console mode (Windows version)


Giovanni Di Maria - calimero22@yahoo.it
since: May 23, 2014



Tutorial


This Tutorial:
Rev. [1] - May 23, 2014
Rev. [24] - Jun 7, 2014






Introduction
This is a short but simple tutorial that explains how to compile Harbour from source, for Android system, in Windows. It explains also how to use Harbour to compile your programs, to use them on your Android Tablet & C.
It's specifically written for beginners that initially encounter some difficulties, building Harbour. Many guides on the Internet are complicated and have the defect of presenting the subject in a confused manner.
The biggest flaw is to show many environment variables and paths to be set, even if they are not needed. In this way the beginners become discouraged and leave the idea of compiling Harbour. This tutorial explains just the basic facts, reducing the rules to follow.
Be careful. The name of folders might change with the various distributions of the programs.
Giovanni Di Maria




Legal Notices
This tutorial is a free document and will remain free. You can view, use, print and redistribute it and/or modify it, without any limitations.




  1. Download Android NDK

    1. Download last Android NDK from https://developer.android.com/tools/sdk/ndk/index.html. It's huge.
    2. Unpack it to c:\android-ndk-r9d folder (or other one).

  2. Download Harbour sources

    1. Download last Harbour sources from https://github.com/harbour/core/archive/master.zip.
    2. Unpack it to c:\core-master folder (or other one).

  3. Compile normally Harbour

    1. Open a console window, with the menu Start -> Run -> cmd
    2. Go to folder of sources of Harbour, by typing cd c:\core-master (or other specified)
    3. Set path for GCC: PATH=C:\hb32\comp\mingw\bin. You must first install GCC (Harbour nigthly has a copy of GCC)
    4. Set an environment variable: SET HB_INSTALL_PREFIX=c:\harbour
    5. Type the command win-make install, followed by "Return" key, to start the building. This process could take long time
    6. At end, close the console window by typing "exit" and press "Return"

  4. Compile Harbour for Android

    1. Open a console window, with the menu Start -> Run -> cmd
    2. Go to folder of sources of Harbour, by typing cd c:\core-master (or other specified) and issue these commands followed by "Return":
    3. set HB_INSTALL_PREFIX=C:\harbour-android
    4. set HB_PLATFORM=android
    5. set HB_COMPILER=gccarm
    6. set HB_CCPREFIX=C:\android-ndk-r9d\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\bin\arm-linux-androideabi-
    7. set HB_HOST_BIN=C:\harbour\bin
    8. set HB_USER_CFLAGS=--sysroot=C:\android-ndk-r9d\platforms\android-9\arch-arm
    9. set HB_USER_DFLAGS=--sysroot=C:\android-ndk-r9d\platforms\android-9\arch-arm
    10. set HB_USER_LDFLAGS=--sysroot=C:\android-ndk-r9d\platforms\android-9\arch-arm
    11. win-make install
    12. At end, close the console window by typing "exit" and press "Return"

  5. Compiling a PRG for Android

    1. Open a console window, with the menu Start -> Run -> cmd
    2. Go to you work directory, with the command cd \test (for example) and press "Return"
    3. Create a PRG file, for example, "Hello World" and name it myprog.prg (for example):
      FUNCTION Main()
         CLEAR SCREEN
         @ 02, 03, 10, 25 BOX "*" COLOR "rb+/n"
         @ 03, 10 SAY " This is " COLOR "rg+/g"
         @ 05, 10 SAY " my first " COLOR "w+/r"
         @ 07, 05 SAY " program in Harbour " COLOR "gb+/b"
         @ 09, 08 SAY " for Android " COLOR "n/w"
         @ 13, 10
         RETURN NIL
      
    4. Issue these commands followed by "Return":
      1. set HB_INSTALL_PREFIX=C:\harbour-android
      2. set HB_PLATFORM=android
      3. set HB_COMPILER=gccarm
      4. set HB_CCPREFIX=C:\android-ndk-r9d\toolchains\arm-linux-androideabi-4.8\prebuilt\windows\bin\arm-linux-androideabi-
      5. set HB_USER_CFLAGS=--sysroot=C:\android-ndk-r9d\platforms\android-9\arch-arm
      6. set HB_USER_LDFLAGS=--sysroot=C:\android-ndk-r9d\platforms\android-9\arch-arm
      7. path c:\harbour\bin
      8. hbmk2 -w3 myprog.prg
    5. The compilation will create a binary file for Android, named "myprog"


  6. Copy and Execute the application on Android

    1. Copy your application to Android, to folder /mnt/sdcard/Download
    2. On Android install and run Android Terminal Emulator (ATE)
    3. Type cd and press "Return". Current folder HOME is executable
    4. Type chmod 775 . and press "Return". (Dot at end)
    5. Copy your application to Android file system with: cp /sdcard/Download/myprog . (Dot at end)
    6. Type chmod 775 myprog to change permissions to your application
    7. Execute your program with ./myprog
    8. Enjoy!!!


Appendix A - Contributors




Appendix B - What users think