Skip to content

docs: explain how Deno.dlopen locates libraries and handles failures#3322

Merged
bartlomieju merged 2 commits into
mainfrom
ffi-loading-libraries
Jun 19, 2026
Merged

docs: explain how Deno.dlopen locates libraries and handles failures#3322
bartlomieju merged 2 commits into
mainfrom
ffi-loading-libraries

Conversation

@bartlomieju

Copy link
Copy Markdown
Member

Feedback on the Deno.dlopen reference asked three questions the docs did not
answer: how Deno locates the library file, whether deno compile can bundle
the .so/.dylib/.dll, and how a failed load is reported. The reference page
itself is generated from upstream JSDoc, so this adds the answers to the FFI
guide it already links to.

The new "Loading libraries" section explains that the path is handed to the
OS dynamic loader, so a relative path resolves against the current working
directory rather than the script, and shows the import.meta.url pattern that
loads a library sitting next to the module from any cwd. It documents
bundling a library into a compiled binary with deno compile --include, and
shows handling load failures with try/catch, noting the distinct messages
for a missing file versus a missing symbol. Every behavior was verified
against a locally built library.

Closes #3146

@bartlomieju
bartlomieju merged commit 4a36d87 into main Jun 19, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feedback: /api/deno/~/Deno.dlopen - Positive

1 participant