Function dlopen

  • Open a library using "bun:ffi"

    Example

    import {dlopen} from 'bun:ffi';

    const lib = dlopen("duckdb.dylib", {
    get_version: {
    returns: "cstring",
    args: [],
    },
    });
    lib.symbols.get_version();
    // "1.0.0"

    This is powered by just-in-time compiling C wrappers that convert JavaScript types to C types and back. Internally, bun uses tinycc, so a big thanks goes to Fabrice Bellard and TinyCC maintainers for making this possible.

    Parameters

    • name: string

      The name of the library or file path. This will be passed to dlopen()

    • symbols: Symbols

      Map of symbols to load where the key is the symbol name and the value is the FFIFunction

    Returns Library

  • Open a library using "bun:ffi"

    Example

    import {dlopen} from 'bun:ffi';

    const lib = dlopen("duckdb.dylib", {
    get_version: {
    returns: "cstring",
    args: [],
    },
    });
    lib.symbols.get_version();
    // "1.0.0"

    This is powered by just-in-time compiling C wrappers that convert JavaScript types to C types and back. Internally, bun uses tinycc, so a big thanks goes to Fabrice Bellard and TinyCC maintainers for making this possible.

    Parameters

    • name: string

      The name of the library or file path. This will be passed to dlopen()

    • symbols: Symbols

      Map of symbols to load where the key is the symbol name and the value is the FFIFunction

    Returns Library

Generated using TypeDoc