---
product: Chilkat
product_version: 11.7.0
language: cpp
language_label: C++
document: language guide
---
> Chilkat 11.7.0 · language=cpp · this file: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/guide.md`
> Class pages: `https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/classes/<Class>.md`

# Chilkat for C++ — language guide — v11.7.0

## 1. Which Chilkat binding this is

This is the **Chilkat C++ library**: classes `CkHttp`, `CkZip`, `CkBinData`, … in `CkHttp.h` etc. (ANSI/UTF-8 `const char *` API). A parallel **Unicode C++** API (`CkHttpW`, `const wchar_t *`) and a **C** API (`HCkHttp` handles, `CkHttp_*` functions) ship in the same download and have their own references (`wcpp/`, `c/`). Properties are methods: getters `get_Xxx()` or the lowercase-initial form for strings (`http.lastErrorText()`), setters `put_Xxx(...)`.

## 2. Install and requirements

Download the library for your compiler and platform — Visual C++, C++Builder, MinGW/MSYS2, GCC/Clang on Linux and Alpine, Xcode, Android NDK — from [https://www.chilkatsoft.com/downloads_cpp.asp](https://www.chilkatsoft.com/downloads_cpp.asp). Add the `include/` directory to the include path and link the static library (`chilkat.lib` / `libchilkat.a`), plus the platform libraries the page lists. No OpenSSL or other third-party dependency.

## 3. Unlocking and object creation

```cpp
#include <CkGlobal.h>
#include <CkHttp.h>

// Required once per process, before any other Chilkat object. Any string unlocks a 30-day trial.
CkGlobal glob;
bool success = glob.UnlockBundle("Anything for 30-day trial");
if (!success) {
    std::cout << glob.lastErrorText() << "\r\n";
    return;
}

CkHttp http;   // objects are usually stack variables, or new/delete
```

- Unlocking only sets a flag in memory: no license files, no network call, so the call is repeated each time the program runs. Extra calls are harmless no-ops; the `Global` object can be discarded afterwards.
- If a program forgets to unlock, Chilkat runs in trial mode and stops working when the trial expires — always include the call, and use the purchased unlock code in production.
- `UnlockBundle` unlocks every class; per-class `UnlockComponent` methods exist only in old code.

## 4. Error model

Chilkat methods **do not throw**. The note under each method on the class page says how it reports failure. String-producing methods come in two forms: an uppercase form with a `CkString &` output argument returning `bool` (`http.QuickGetStr(url, ckStr)`), and a lowercase-initial form returning `const char *` that is **NULL on failure** (`const char *s = http.quickGetStr(url)`). The returned `const char *` points at memory owned by the object and is valid only until the next call on that object — copy it if you keep it. Object-returning methods return a pointer that is NULL on failure and that **the caller must delete**. Boolean status methods return `false`; for an `int` result check `get_LastMethodSuccess()`. `lastErrorText()` holds the diagnostic in every case.

Literals in C++: true is `true`, false is `false`, null/none is `NULL`.

## 5. Strings, bytes and encodings

- Strings are `const char *` in UTF-8 (set `put_Utf8(true)`, the default in v11, to interpret arguments and results as UTF-8; ANSI otherwise). A `charset` argument names the encoding of the *bytes* being produced or read. See [https://www.chilkatsoft.com/cpp_strings.asp](https://www.chilkatsoft.com/cpp_strings.asp).
- Binary data goes through `CkByteData` (`getData()`, `getSize()`, `append(...)`) and `CkBinData` (`Bd` methods); text through `CkString` and `CkStringBuilder` (`Sb` methods).
- Methods with `2`/`3` suffixes or `Quick*` prefixes are distinct members, not overloads.

## 6. Object lifetime and threading

Stack objects are released at scope exit; heap objects with `delete`. **Objects returned by methods** (e.g. an `CkHttpResponse *`) are owned by the caller and must be `delete`d — the most common leak, see [https://www.chilkatsoft.com/cpp_memory_leaks.asp](https://www.chilkatsoft.com/cpp_memory_leaks.asp). Strings returned by lowercase methods are owned by the object; copy them before the next call.

A Chilkat object may be used from any thread, but **one object must not be used by two threads at the same time**: create one object per thread or protect it with a lock. Objects are independent — there is no shared global state other than the unlock flag and the few `Global` settings.

## 7. Progress callbacks and async

Progress events are supported: see the "Events and callbacks" section of a class page for the event list and how to attach a handler in this binding (AbortCheck, PercentDone, ProgressInfo and TaskCompleted are the standard ones). Every method with an "Async variant" line also has an `XAsync` twin that returns a `Task` immediately; poll `Finished` or use the `TaskCompleted` event, then read the result from the task. No new Async methods are added from 11.7.0 on. In C++, derive from the class's progress class (e.g. `CkHttpProgress` / `CkBaseProgress`), override the event methods, and pass the instance to `put_EventCallbackObject(...)` — see [https://www.chilkatsoft.com/cpp_event_callbacks.asp](https://www.chilkatsoft.com/cpp_event_callbacks.asp).

## 8. Common mistakes an AI makes with this binding

1. Forgetting to `delete` an object returned by a method, or deleting one that is a member/stack object.
2. Keeping a `const char *` returned by a lowercase method across another call on the same object (it is overwritten).
3. Using `std::string` or `std::vector<unsigned char>` where the API takes `CkString`/`CkByteData`.
4. Mixing the ANSI (`CkHttp`), Unicode (`CkHttpW`) and C (`HCkHttp`) APIs in one call chain.
5. Omitting `Global.UnlockBundle` (the program runs in trial mode and stops working after 30 days).
6. Inventing members by analogy with other libraries. If a member is not on the class page, it does not exist — look it up rather than guessing.
7. Using deprecated members that older examples still show. The class page lists each one with its replacement; `deprecated.md` lists them all.
8. Ignoring the failure path. Every Chilkat method reports failure (see each method's note); `LastErrorText` says why, and printing it is the first debugging step.
9. Using one Chilkat object from two threads at the same time. Create one object per thread, or protect it with a lock.

## 9. Instructions block for coding agents

Paste into `CLAUDE.md`, `.cursor/rules`, or Copilot instructions:

```
This project uses Chilkat 11.7.0 from C++ (classes CkHttp, CkZip, ... from the Chilkat C++ library, headers CkHttp.h etc.).
- Reference: https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/ — read guide.md once, then classes/<Class>.md for each class used.
- Create a CkGlobal and call UnlockBundle(...) once at startup.
- Properties are methods: put_Xxx(v) / get_Xxx(); string getters are lowercase-initial (lastErrorText()).
- Chilkat methods never throw: lowercase string methods return NULL on failure, status methods return false, returned objects must be deleted; print obj.lastErrorText() on failure.
- Never use a member that is not on the class page; never use members listed as deprecated.
```

## 10. Classes

[Class index for C++](https://www.chilkatsoft.com/ai-docs/v/11.7.0/cpp/index.md)
