Harbour Compiler

Modern open-source xBase compiler for cross-platform development

What is Harbour?

A powerful, cross-platform xBase compiler that brings modern capabilities to classic xBase development.

Overview

🌍 Cross-Platform

Compile your xBase code for Windows, Linux, macOS, and many other platforms.

📖 Open Source

Completely free and open-source with an active community and continuous development.

⚡ Modern Features

Unicode support, advanced debugging, and integration with modern development tools.

🔧 C Integration

Easy integration with C libraries and the ability to create C extensions.

Installation Guide

Choose your platform and follow the installation steps.

Setup
# Ubuntu/Debian
sudo apt update
sudo apt install harbour

# Fedora/RHEL
sudo dnf install harbour

# Arch Linux (AUR)
yay -S harbour

# Or compile from source:
cd $XBASE_WORKSPACE
git clone https://github.com/harbour/core harbour-core
cd harbour-core
make
sudo make install
Note: Package availability varies by distribution. Source compilation recommended for latest features.

📦 Prebuilt Binaries

Download precompiled Harbour binaries for Windows from the official releases.

# Using package managers:

# Chocolatey
choco install harbour

# MSYS2
pacman -S mingw-w64-x86_64-harbour

# Manual installation:
# 1. Download from GitHub releases
# 2. Extract to C:\harbour
# 3. Add C:\harbour\bin to PATH
# 4. Set HB_PATH=C:\harbour
Download Releases
# Using Homebrew
brew install harbour

# Using MacPorts
sudo port install harbour

# From source with Xcode tools:
xcode-select --install
cd $XBASE_WORKSPACE
git clone https://github.com/harbour/core harbour-core
cd harbour-core
make
sudo make install
Requirement: Xcode Command Line Tools must be installed first.

⚠️ Prerequisites

Make sure you have a C compiler (GCC, Clang, or MSVC) and make/cmake installed before proceeding.

# Clone the repository
cd $XBASE_WORKSPACE
git clone https://github.com/harbour/core harbour-core
cd harbour-core

# Configure environment (optional)
export HB_COMPILER=gcc
export HB_BUILD_OPTIM=yes

# Build Harbour
make

# Install system-wide (Linux/macOS)
sudo make install

# Windows: copy bin directory to desired location
# and add to PATH environment variable
Build Guide

Quick Start

Create and compile your first Harbour program.

Tutorial

1. Create a Hello World Program

// hello.prg
PROCEDURE Main()
    ? "Hello, World from Harbour!"
    ? "Current date:", Date()
    ? "Current time:", Time()
    
    WAIT "Press any key to exit..."
RETURN

2. Compile and Run

# Compile to executable
hbmk2 hello.prg

# Run the program
./hello

# Alternative: compile and run in one step
hbmk2 -run hello.prg

💡 Pro Tip

Use hbmk2 instead of direct harbour command. It's the modern build tool that handles dependencies and linking automatically.

Advanced Features

Explore Harbour's modern capabilities beyond basic xBase compatibility.

Advanced

🗄️ Database Support

Built-in support for DBF, MySQL, PostgreSQL, SQLite, and many other database formats.

Database drivers
  • DBFNTX, DBFNSX, DBFCDX for DBF files
  • MySQL native driver
  • PostgreSQL native driver
  • SQLite3 support
  • ODBC connectivity

🌐 Web Development

Create web applications with Harbour's built-in web server and CGI support.

Web capabilities
  • Built-in HTTP server
  • CGI script support
  • JSON parsing and generation
  • REST API development
  • Template engine support

📱 GUI Development

Multiple GUI frameworks available for desktop application development.

GUI options
  • GTWVT for Windows console
  • HbQt for Qt-based GUIs
  • Fivewin integration
  • GTK+ bindings
  • Web-based interfaces

🔗 Language Integration

Call C/C++ libraries and integrate with other programming languages.

Integration features
  • C function calling
  • Dynamic library loading
  • COM object support (Windows)
  • Regular expressions
  • XML/JSON processing

Recommended Project Structure

Organize your Harbour projects for maximum productivity.

Best Practices
$XBASE_WORKSPACE/
├── harbour-core/          # Harbour compiler source
├── HB_Projects/          # Your Harbour projects
│   ├── MyApp/
│   │   ├── src/          # Source code (.prg files)
│   │   ├── include/      # Header files (.ch)
│   │   ├── lib/          # Libraries
│   │   ├── build/        # Compiled output
│   │   ├── docs/         # Documentation
│   │   ├── tests/        # Test files
│   │   ├── hbmk.hbm      # Build configuration
│   │   └── README.md
│   └── Common_Libs/      # Shared libraries
│       ├── utils/
│       ├── database/
│       └── gui/
└── Tools/                # Development tools
    ├── editors/
    ├── debuggers/
    └── utilities/

Sample hbmk.hbm Configuration

# hbmk.hbm - Build configuration file
-hblib

# Project settings
-o../build/myapp

# Include paths
-I./include
-I../Common_Libs/include

# Library paths
-L./lib
-L../Common_Libs/lib

# Source files
src/*.prg

# Libraries to link
-lhbcommon
-lhbcpage

# Debug mode (remove for release)
-debug

Development Tools & IDEs

Recommended tools for Harbour development.

Tools

🖥️ Console-Based

Traditional command-line development tools.

  • hbmk2 - Modern build tool
  • harbour - Core compiler
  • hbrun - Script runner
  • hbtest - Testing framework

📝 Text Editors

Editors with Harbour syntax support.

  • VS Code - With xBase extensions
  • Vim/Neovim - Classic editor
  • Emacs - With xbase-mode
  • Sublime Text - With syntax packages

🎯 Specialized IDEs

IDEs specifically designed for xBase development.

  • HbIDE - Harbour-specific IDE
  • xMate - Cross-platform xBase IDE
  • Code::Blocks - With Harbour plugin
  • Qt Creator - For HbQt projects

🐛 Debugging Tools

Debug and profile your Harbour applications.

  • hbdbg - Built-in debugger
  • Valgrind - Memory debugging (Linux)
  • GDB - GNU debugger integration
  • Harbour Profiler - Performance analysis

Code Examples

Common Harbour programming patterns and examples.

Examples
// Variables and arrays
LOCAL cName := "John Doe"
LOCAL nAge := 25
LOCAL aItems := {"Apple", "Banana", "Cherry"}

// Control structures
IF nAge >= 18
    ? cName + " is an adult"
ELSE
    ? cName + " is a minor"
ENDIF

// Loops
FOR nI := 1 TO LEN(aItems)
    ? "Item " + STR(nI) + ": " + aItems[nI]
NEXT

// Functions
FUNCTION GetFullName(cFirst, cLast)
    RETURN cFirst + " " + cLast

// Error handling