Skip to content

deno dlopen fails to open an embedded library in windows #31218

@sigmaSd

Description

@sigmaSd

Version: deno 2.5.6 (stable, release, x86_64-unknown-linux-gnu)

This bug maybe a true deno windows bug or maybe due to either:

  • I'm cross compiling from linux
  • I'm using wine in linux instead of windows (I dont have windows nearby)

To reproduce

  • get a windows dll
  • for example here is what I have
ls
a*  a.exe*  a.ts  libglib-2.0-0.dll*  libglib-2.0.so*  libm.so
  • a.ts
const path = (Deno.build.os === "linux")
  ? import.meta.dirname + "/libglib-2.0.so"
  : import.meta.dirname + "/libglib-2.0-0.dll";

console.log(path);
Deno.statSync(path);
console.log("file exists!");

Deno.dlopen(path, {});
  • deno compile --allow-ffi --target x86_64-pc-windows-msvc --include libglib-2.0-0.dll a.ts
  • wine a.exe
C:\users\mrcool\Temp\deno-compile-a.exe/libglib-2.0-0.dll
file exists!
error: Uncaught (in promise) Error: Could not open library: Mo
dule not found.

Deno.dlopen(path, {});
     ^
    at new DynamicLibrary (ext:deno_ffi/00_ffi.js:
457:42)
    at Object.dlopen (ext:deno_ffi/00_ffi.js:
563:10)
    at file:///C:/users/mrcool/Temp/deno-compile-a.exe/a.ts:
9:6

if I compile to the linux target, it works as expected

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions