Read, write, and search Lance datasets from C or C++. The library exposes a C ABI and header-only C++ RAII wrappers. Scans and writes exchange Arrow batches through the Arrow C Data Interface.
Prebuilt packages support Linux x86_64 and AArch64 (glibc 2.28+), macOS arm64, and Windows x64 and ARM64 with the static /MT CRT. The C API requires C11; the C++ wrapper requires C++20. Download stable packages from the latest stable release; the releases page lists previews, older releases, and their notes.
On Linux x86_64, use a C++20 compiler and CMake 3.22+ to build this C++ consumer against the prebuilt library. The release archive supplies the compiled library; the C API itself requires C11. A shallow checkout of the same release tag supplies the standalone example and sample dataset; copy the example out before building. You can run this without a Rust toolchain.
The C and C++ quickstart follows the same installed-package flow and adds the C++ write/index/query workflow, the C scan example, and links to the generated API reference. The commands below are the short archive verification path.
Each .tar.zst download contains the full SDK with static and shared libraries, C and C++ headers, the license, and CMake and pkg-config metadata. Windows archives also include the DLL import library. For releases that list a .tar.xz archive, use that filename with the same checksum and extraction commands.
mkdir lance-c-quickstart && cd lance-c-quickstart
# Copy the tag and archive filename from https://github.com/lance-format/lance-c/releases/latest
TAG=vX.Y.Z
ARCHIVE=lance-c-$TAG-x86_64-unknown-linux-gnu.tar.zst
curl -fLO "https://github.com/lance-format/lance-c/releases/download/$TAG/$ARCHIVE"
curl -fLO "https://github.com/lance-format/lance-c/releases/download/$TAG/$ARCHIVE.sha512"
sha512sum -c "$ARCHIVE.sha512"
mkdir install
cmake -E chdir install cmake -E tar xf "../$ARCHIVE"
git clone --depth 1 --branch "$TAG" https://github.com/lance-format/lance-c.git source
cp -R source/examples/cmake-consumer consumer
cmake -S consumer -B build \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$PWD/install"
cmake --build build --target consumer
./build/consumer "source/test_data/v0.27.1/pq_in_schema"Expected output:
rows: 512, version: 2
The consumer directory has no dependency on the checkout layout and also runs against any other Lance dataset. For other platforms, see the release archives and platform requirements. Pair the library with examples whose API matches the release you downloaded.
With CMake, set CMAKE_PREFIX_PATH to the unpacked archive. For an existing target named my_app:
find_package(LanceC CONFIG REQUIRED)
target_link_libraries(my_app PRIVATE LanceC::lance_c)C and C++ applications using <lance/lance.h> link LanceC::lance_c.
For the header-only C++20 wrapper <lance/lance.hpp>, use the same target and
request the language level explicitly:
target_compile_features(my_app PRIVATE cxx_std_20)
target_link_libraries(my_app PRIVATE LanceC::lance_c)The v0.2.0 release archive provides LanceC::lance_c and its _static and
_shared variants, and ships the umbrella lance.h and lance.hpp. Newer
packages also provide LanceC::lance_cpp, which adds the same C++20
requirement, and the split domain headers. The explicit snippet works with both.
CMake selects the static library by default. Configure with -DLanceC_LINK=shared to link the shared library, which exports only the lance_* C ABI and hides its embedded native symbols from those exports. Prefer it when the host itself links a library that exports the same native symbol names, such as ZSTD_* or LZ4_*. See choosing static or shared linkage. On Windows, static consumers must use the Release /MT runtime. See Windows linking instructions. The public C ABI is checked against the published export baseline; see ABI compatibility.
With pkg-config, point PKG_CONFIG_PATH at the archive's lib/pkgconfig:
export PKG_CONFIG_PATH=/path/to/lance-c-install/lib/pkgconfig
cc my_app.c $(pkg-config --cflags --libs lance-c) -o my_appAdd --static and link liblance_c.a explicitly when using the static archive; see pkg-config usage.
- C++ — Include lance/lance.hpp. Open a dataset with
lance::Dataset::open(uri), callcount_rows()or create a scanner withscan(). Handles own their resources and failures throwlance::Error. The CMake consumer is a complete program; the same directory also has a write/index/query workflow. - C — Include lance/lance.h, the umbrella header. The C11 scan example opens a dataset, iterates all Arrow batches, prints errors, and releases the batches, stream, and Lance handles. Set
LANCE_C_PREFIXto the unpacked archive when building it with Make.
- C and C++ quickstart for an installed-package C++ write/query example and a C scan example.
- C and C++ API guide for scans, vector search, writes, transactions, dataset maintenance, opt-in diagnostic logging, Tokio worker-thread configuration, and process lifetime during embedding.
- API reference for the hosted Doxygen HTML reference (see Generated API reference for local rendering and CI checks).
- Segment-scoped scalar scans and publishing blob data for specialized workflows.
- Building and packaging for platform toolchains, source builds, and releases.
See CONTRIBUTING.md for local build, test, Doxygen and ABI expectations. Published changes are summarized in CHANGELOG.md.