System libraries
Path resolution
How UnFFI finds dynamic libraries.
dlopen accepts exact paths, extensionless local paths, and bare library names. The path resolver expands extensions for the current platform and preserves explicit names such as libc.so.6, CoreFoundation.framework/CoreFoundation, and kernel32.dll.
import { resolveLibraryPathSync } from 'unffi/paths'
resolveLibraryPathSync('./libmath')
// ./libmath.dylib, ./libmath.so, or .\\libmath.dll depending on platformBinding path metadata
Generated system modules use resolveBindingLibraryPathSync internally. It applies this order:
open*(pathOverride)- the module's
UNFFI_*_PATHenvironment variable - the module's built-in candidates
import { resolveBindingLibraryPathSync } from 'unffi/paths'
import { libcLibraryPaths } from 'unffi/linux/libc'
const path = resolveBindingLibraryPathSync(libcLibraryPaths, {
platform: 'linux',
})Environment variables are opt-in. UnFFI does not automatically emulate LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, or PATH.
Platform notes
- macOS framework paths may resolve through the dyld shared cache.
- Linux modules prefer versioned sonames such as
libc.so.6. - Windows modules use DLL names such as
kernel32.dlland can be overridden when needed.