Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

feat: ffi example #108

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

feat: ffi example #108

wants to merge 3 commits into from

Conversation

load1n9
Copy link
Contributor

@load1n9 load1n9 commented Oct 23, 2023

No description provided.

// Next, we import the FFI library from Deno.
const julia = Deno.dlopen(
// Change .dll to .dylib on macOS and .so on Linux
`libjulia.dll`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure this should be the default, but no strong feelings.

data/ffi.ts Show resolved Hide resolved
@lino-levan
Copy link
Contributor

I think this example makes a lot of sense to me. Just a few nits.

@lino-levan
Copy link
Contributor

@hashrock what do you think?

@hashrock hashrock self-requested a review November 3, 2023 04:54
@hashrock
Copy link
Contributor

hashrock commented Nov 4, 2023

hmm, looks interesting, but I couldn't test this on my M2 mac mini.
Has anyone tried this on OSX?

installed julia 1.9.3 with homebrew, and I changed the lib path:

const julia = Deno.dlopen(
  // Change .dll to .dylib on macOS and .so on Linux
  `/opt/homebrew/lib/libjulia.dylib`,
  SYMBOLS,
).symbols;

and I got this error:

hashrock@hashrocknoMac-mini denobyexample % deno run --unstable --allow-ffi --reload http://localhost:8000/ffi.ts
fatal: error thrown and no exception handler available.
InitError(mod=:Base, error=ErrorException("could not load symbol "jl_options":
dlsym(RTLD_DEFAULT, jl_options): symbol not found"))
ijl_errorf at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
ijl_dlsym at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
ijl_load_and_lookup at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
JLOptions at ./options.jl:66 [inlined]
reinit_stdio at ./libuv.jl:122
__init__ at ./Base.jl:523
jfptr___init___40974 at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/sys.dylib (unknown line)
ijl_apply_generic at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
jl_module_run_initializer at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
_finish_julia_init at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
julia_init at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
ijl_init_with_image at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
ijl_init at /opt/homebrew/Cellar/julia/1.9.3_1/lib/julia/libjulia-internal.1.9.dylib (unknown line)
ffi_call_SYSV at /Users/hashrock/.deno/bin/deno (unknown line)
ffi_call_int at /Users/hashrock/.deno/bin/deno (unknown line)
_ZN105_$LT$extern$u20$$u22$C$u22$$u20$fn$LP$A0$RP$$u20$.$GT$$u20$R$u20$as$u20$v8..support..CFnFrom$LT$F$GT$$GT$7mapping4c_fn17h1c9b28d765cfd2e9E at /Users/hashrock/.deno/bin/deno (unknown line)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants