This repository contains comprehensive C FFI bindings for LanceDB, allowing you to use all LanceDB functionality from C and C++ applications.
├── src/ # Rust FFI implementation
│ ├── lib.rs # Main library entry point
│ ├── connection.rs # Connection management
│ ├── table.rs # Table operations and data manipulation
│ ├── query.rs # Complete query API implementation
│ ├── index.rs # Index management
│ ├── error.rs # Error handling and reporting
│ └── types.rs # Type definitions and conversions
├── include/
│ └── lancedb.h # Complete C header file with Arrow C ABI
├── examples/
│ ├── full.cpp # C++ example using Arrow. Covering most of the API
│ └── simple.cpp # C++ example using Arrow. Similar to rust/examples/simple.rs
├── tests/ # C++ unit tests using Catch2
├── docs/ # Documentation definitions
├── Cargo.toml # Rust crate configuration
├── CMakeLists.txt # CMake build configuration
└── README.md # This file
- Rust toolchain (rustc, cargo)
- CMake (3.15 or later)
- C++ compiler with C++20 support (gcc, clang)
- Apache Arrow C++ library
- pkg-config
-
Build everything using CMake:
mkdir -p build cd build cmake .. make -
Run the examples:
./simple ./full
If you prefer to build manually:
-
Build the Rust library:
cargo build --release
-
Compile the C++ simple example with Arrow:
g++ -std=c++20 -Wall -Wextra -O2 \ -I./include \ $(pkg-config --cflags arrow) \ -o examples/simple examples/simple.cpp \ -L./target/release -llancedb \ $(pkg-config --libs arrow) \ -Wl,-rpath,./target/release -
Run the example:
./examples/simple
- Tests use the Catch2 framework. No need to install it as it will be fetched as part of the build process
- If valgrind is installed, some tests will run under valgrind and will fail on memory errors or definite memory leaks
-
Build Tests
mkdir -p build cd build cmake .. -DBUILD_TESTS=ON make -
Run Tests
ctest -j 6
The LanceDB C API has comprehensive documentation generated from the header file comments.
The documentation is automatically published to GitHub Pages on every push to main:
-
Install documentation tools:
- Install Doxygen (extracts API documentation from
include/lancedb.h) - Install Sphinx and Breathe (generate HTML documentation):
pip install -r docs/requirements.txt
- Install Doxygen (extracts API documentation from
-
Build the documentation:
mkdir -p build cd build cmake .. -DBUILD_DOCS=ON make docs