# Chilkat for Lazarus / Free Pascal

**New supported language/platform** — September 2026

Chilkat is now available for **Lazarus / Free Pascal (FPC)**. This is a new, fully generated Object Pascal API in which each Chilkat class is wrapped by its own self-contained Pascal unit, calling into a native Chilkat shared library that is loaded dynamically at runtime.

## Overview

- One unit per class: `Chilkat.Http.pas`, `Chilkat.Zip.pas`, `Chilkat.Crypt2.pas`, etc., each providing a Pascal class (`THttp`, `TZip`, `TCrypt2`, ...) derived from `TChilkatBase`.
- No compile-time linking. The units resolve all functions at runtime from the Chilkat C bridge library via `CkDllLoader.pas` — nothing to add to your linker settings, and no import libraries.
- Strings are plain Pascal `string` throughout. All conversions to and from the library's UTF-8 interface are handled internally.
- Chilkat object parameters and return values are typed as `TChilkatBase`, so no wrapper unit ever references another — there are no circular `uses` dependencies, and you only add the units you actually use.

## Supported platforms

The runtime library (`chilkat_c_bridge`) is provided for:

| OS | Architectures | Library |
|---|---|---|
| Windows | x86, x64, ARM64 | `chilkat_c_bridge_win32.dll`, `chilkat_c_bridge_x64.dll`, `chilkat_c_bridge_arm64.dll` |
| Linux | x86_64, arm64, x86, armhf | `libchilkat_c_bridge_<arch>.so` |
| macOS | Universal (Apple Silicon + Intel) | `libchilkat_c_bridge.dylib` |

`CkDllLoader.pas` selects the correct library name for the current OS and architecture automatically; a custom load path can also be specified.

## Getting started

Add the companion units (`Chilkat.Base.pas`, `Chilkat.Utils.pas`, `CkDllLoader.pas`) plus the class units you need to your project, and make sure the Chilkat shared library is on the library search path.

```pascal
uses
  Chilkat.Base, Chilkat.Http;

var
  http: THttp;
  html: string;
begin
  http := THttp.Create;
  if not http.IsValid then
    raise Exception.Create('Failed to load the Chilkat library.');

  html := http.QuickGetStr('https://www.example.com/');
  if not http.LastMethodSuccess then
    WriteLn(http.LastErrorText);

  http.Free;
end;
```

Every class includes the standard Chilkat diagnostic properties: `LastErrorText`, `LastErrorXml`, `LastErrorHtml`, `LastMethodSuccess`, `DebugLogFilePath`, `VerboseLogging`, and `Version`.

## Event callbacks

Event-capable classes provide three synchronous event callbacks as standard Pascal *of object* event properties: `OnAbortCheck`, `OnPercentDone`, and `OnProgressInfo`. The handler types are declared in `Chilkat.Base.pas`:

```pascal
TChilkatAbortCheckEvent   = function(Sender: TChilkatBase): Boolean of object;
TChilkatPercentDoneEvent  = function(Sender: TChilkatBase; PctDone: Integer): Boolean of object;
TChilkatProgressInfoEvent = procedure(Sender: TChilkatBase; const Name, Value: string) of object;
```

Assign a method of one of your own objects to receive callbacks; assign `nil` to unhook:

```pascal
function TMyForm.HttpPercentDone(Sender: TChilkatBase; PctDone: Integer): Boolean;
begin
  ProgressBar1.Position := PctDone;
  Result := False;   // return True to abort the running method
end;

...
http.OnPercentDone := Self.HttpPercentDone;
http.HeartbeatMs := 250;   // OnAbortCheck fires 4 times per second
```

All Chilkat methods are synchronous, so callbacks arrive on the thread that called the method — if you call from the main thread, it is safe to update UI elements in the handler. The `HeartbeatMs` property controls `OnAbortCheck` frequency (the default of 0 disables AbortCheck events). Returning `True` from an `OnAbortCheck` or `OnPercentDone` handler aborts the method in progress.

## Scope notes

- **Synchronous API only.** Chilkat for Lazarus/FPC does not include the async method variants (`*Async`), and the `Task` and `TaskChain` classes are not part of this API.
- The primary target is Lazarus/FPC (`{$MODE DELPHI}` is set automatically when compiling with FPC). Delphi developers should continue to use the dedicated Chilkat Delphi offerings.

## Reference documentation

Complete online reference documentation is available for every class, including per-class event documentation with Pascal implementation examples for each callback.
