Installation
This guide will walk you through setting up the Binary Ninja API for your preferred programming language.Prerequisites
- Binary Ninja installed with a valid license
- For headless/standalone tools: A license with headless support
- C++ compiler (for C++ and Rust development)
Version Matching
Python API
The Python API is the easiest to get started with and is included with your Binary Ninja installation.Locate the Python API
The Python API is automatically installed with Binary Ninja. You just need to add it to your Python path.Add this to your shell profile (
- macOS
- Linux
- Windows
.bashrc, .zshrc, etc.) for persistent access.C++ API
The C++ API requires building from source using CMake.Configure Build
Create an out-of-source build directory and configure:
Common CMake Options:
-DBN_INSTALL_DIR=/path/to/binaryninja- Specify Binary Ninja location if not in default path-DBN_API_BUILD_EXAMPLES=ON- Build example plugins-DHEADLESS=ON- Build without UI dependencies (for headless installations)-DCMAKE_BUILD_TYPE=Release- Build optimized release version
- macOS
- Linux
- Windows
C++ Project Setup
To use the API in your CMake project:CMakeLists.txt
Rust API
The Rust API provides type-safe bindings with modern language features.Add Dependencies
Add to your For a specific version, use the commit from
Cargo.toml:Cargo.toml
api_REVISION.txt:Cargo.toml
Create build.rs
Standalone executables need a
build.rs to link against binaryninjacore:build.rs
Plugins don’t need
build.rs - only standalone executables require the build script.For Plugins: Configure Library Type
If building a plugin, configure
Cargo.toml for dynamic linking:Cargo.toml
Rust Plugin Setup
For a Rust plugin, create the initialization function inlib.rs:
lib.rs
Troubleshooting
Binary Ninja Core Not Found (C++)
Binary Ninja Core Not Found (C++)
This error means CMake couldn’t locate your Binary Ninja installation.Solution: Specify the installation path explicitly:Default paths:
- macOS:
/Applications/Binary Ninja.app/Contents/MacOS - Linux:
~/binaryninjaor/opt/binaryninja - Windows:
C:\Program Files\Vector35\BinaryNinja
64-bit Architecture Required
64-bit Architecture Required
Binary Ninja is 64-bit only. Ensure your compiler targets 64-bit:Windows MSVC:Other platforms: Use a 64-bit compiler toolchain.
License Errors
License Errors
Some API features require specific license types:
- Headless operations (standalone tools): Requires headless license
- UI plugins: Requires standard license
- Check your license at: Help → View License in Binary Ninja
Rust: DEP_BINARYNINJACORE_PATH not found
Rust: DEP_BINARYNINJACORE_PATH not found
Ensure
binaryninjacore-sys is in your dependencies and you have a build.rs file.The environment variable is set by the binaryninjacore-sys build script.