Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Haifengl Smile Native BLAS LAPACK ARPACK

From Leeroopedia


Knowledge Sources
Domains Infrastructure, Linear_Algebra, Native_Libraries
Last Updated 2026-02-08 22:00 GMT

Overview

Native BLAS, LAPACK, and ARPACK libraries required for Smile's linear algebra operations via Java Foreign Function Interface.

Description

Smile's tensor module uses Java's Foreign Function & Memory API (Project Panama / jextract) to call native BLAS, LAPACK, and ARPACK routines. The bindings are auto-generated by `jextract` from C headers. Platform-specific library selection is handled at runtime: macOS uses the built-in Accelerate framework, Linux uses OpenBLAS, and Windows uses pre-built `libopenblas.dll`. ARPACK is loaded separately as `arpack` on all platforms.

Usage

Use this environment for any matrix decomposition, linear system solving, or eigenvalue computation workflow. It is required by the DenseMatrix, SVD, EVD, LU, QR, Cholesky, and ARPACK implementations. Without these native libraries, any call to `DenseMatrix.mm()`, `DenseMatrix.lu()`, `DenseMatrix.svd()`, `DenseMatrix.eigen()`, or `ARPACK.syev()` will fail with `UnsatisfiedLinkError`.

System Requirements

Category Requirement Notes
OS Linux, macOS, or Windows Platform-specific library selection at runtime
Linux `libopenblas-dev`, `libarpack2` Install via apt
macOS ARPACK (`brew install arpack`) BLAS/LAPACK from built-in Accelerate framework
Windows `libopenblas.dll`, `arpack.dll` Pre-built DLLs provided in Smile release `bin/` directory
JVM Flag `--enable-native-access=ALL-UNNAMED` Required for Foreign Function API calls

Dependencies

System Packages (Linux/Ubuntu)

  • `libopenblas-dev` (provides both BLAS and LAPACK)
  • `libarpack2` (ARPACK sparse eigenvalue solver)

System Packages (macOS)

  • Accelerate framework (built-in, provides BLAS + LAPACK)
  • `arpack` (via Homebrew: `brew install arpack`)

System Packages (Windows)

  • `libopenblas.dll` (from Smile release package `bin/` directory)
  • `arpack.dll` (from Smile release package `bin/` directory)
  • Must add DLL directory to system `PATH`

Java System Properties (Override)

  • `smile.lib.blas` - Override BLAS library name (default: platform-dependent)
  • `smile.lib.lapack` - Override LAPACK library name (default: platform-dependent)

Credentials

No credentials required for native library installation.

Quick Install

# Linux (Ubuntu/Debian)
sudo apt update
sudo apt install -y libopenblas-dev libarpack2

# macOS
brew install arpack
# Note: BLAS/LAPACK provided by Accelerate framework (pre-installed)
# Workaround for SIP: copy libarpack.dylib to working directory if needed

# Windows: Download Smile release package and add bin/ to PATH

Code Evidence

Platform-specific BLAS library selection from `base/src/main/java/smile/linalg/blas/cblas_h.java:58-66`:

static final String OS = System.getProperty("os.name", "linux").toLowerCase().split(" ")[0];
static final String LIBRARY_NAME = System.getProperty("smile.lib.blas", switch (OS) {
    case "mac" -> "blas"; // macOS's builtin Accelerate framework
    case "windows" -> "libopenblas"; // ARPACK depends on this name
    default -> "openblas"; // OpenBLAS
});
static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.libraryLookup(
    System.mapLibraryName(LIBRARY_NAME), LIBRARY_ARENA)
    .or(SymbolLookup.loaderLookup())
    .or(Linker.nativeLinker().defaultLookup());

Platform-specific LAPACK library selection from `base/src/main/java/smile/linalg/lapack/clapack_h_1.java:58-66`:

static final String OS = System.getProperty("os.name", "linux").toLowerCase().split(" ")[0];
static final String LIBRARY_NAME = System.getProperty("smile.lib.lapack", switch (OS) {
    case "mac" -> "lapack"; // macOS's builtin Accelerate framework
    case "windows" -> "libopenblas"; // ARPACK depends on this name
    default -> "openblas"; // OpenBLAS
});

ARPACK library loading from `base/src/main/java/smile/linalg/arpack/arpack_h.java:58-60`:

static final SymbolLookup SYMBOL_LOOKUP = SymbolLookup.libraryLookup(
    System.mapLibraryName("arpack"), LIBRARY_ARENA)
    .or(SymbolLookup.loaderLookup())
    .or(Linker.nativeLinker().defaultLookup());

Symbol resolution with error from `base/src/main/java/smile/linalg/blas/cblas_h.java:31-34`:

static MemorySegment findOrThrow(String symbol) {
    return SYMBOL_LOOKUP.find(symbol)
        .orElseThrow(() -> new UnsatisfiedLinkError("unresolved symbol: " + symbol));
}

Common Errors

Error Message Cause Solution
`UnsatisfiedLinkError: unresolved symbol: cblas_dgemm` OpenBLAS not installed `sudo apt install libopenblas-dev` (Linux)
`UnsatisfiedLinkError: unresolved symbol: dsaupd_` ARPACK not installed `sudo apt install libarpack2` (Linux) or `brew install arpack` (macOS)
`java.lang.foreign` access denied Missing JVM flag Add `--enable-native-access=ALL-UNNAMED` to JVM args
Library not found on macOS SIP blocking DYLD_LIBRARY_PATH Copy `libarpack.dylib` to application working directory
Library not found on Windows DLL directory not in PATH Add Smile `bin/` directory to system PATH

Compatibility Notes

  • macOS: Uses built-in Accelerate framework for BLAS/LAPACK. System Integrity Protection (SIP) may block `DYLD_LIBRARY_PATH`; workaround is to copy `libarpack.dylib` to the working directory.
  • Windows: The BLAS library must be named `libopenblas` (not `openblas`) because ARPACK depends on this specific name.
  • Linux: Uses OpenBLAS for both BLAS and LAPACK. The `libopenblas-dev` package provides both.
  • Override: Library names can be overridden via system properties `smile.lib.blas` and `smile.lib.lapack`.
  • jextract: FFI binding classes are auto-generated by jextract and should not be manually edited.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment