Skip to content

source build command

Compile the currently downloaded llama.cpp source code

INFO

If the build fails on macOS with the error "/usr/bin/cc" is not able to compile a simple test program, try running xcode-select --install to install the Xcode command line tools.

Programmatically calling the source build command in your code

To programmatically call this command in your code, call the BuildLlamaCppCommand function:

typescript
import {
BuildLlamaCppCommand
} from "node-llama-cpp/commands";
await
BuildLlamaCppCommand
({});

Note: The node-llama-cpp/commands import is subject to change and is unsupported inside Electron

Usage

shell
npx --no node-llama-cpp source build

Options

Option Description
-a [string], --arch [string] The architecture to compile llama.cpp for (string)
-t [string], --nodeTarget [string] The Node.js version to compile llama.cpp for. Example: v18.0.0 (string)
--gpu [string] Compute layer implementation type to use for llama.cpp (default: auto) (string)

choices: auto, metal, cuda, vulkan, false

--noUsageExample, --nu Don't print code usage example after building (default: false) (boolean)
-h, --help Show help
-v, --version Show version number

To set custom cmake options that are supported by llama.cpp's cmake build, set an environment variable of the option prefixed with NODE_LLAMA_CPP_CMAKE_OPTION_.