babashka 2026-11-17

What would prevent ffi/load-library from being able to load a library. The library has just data. I've loaded it with JNA, FFI in Julia & Python, and as a dynamic library in C. I wanted to load it from ~/.local/lib & when that failed, I put a copy in /usr/local/lib/ . No success. I guess I'll try java.lang.foreign directly & see if I have the same problem.

✅ 1

it would be helpful if you could paste the error output somewhere readable for us? and perhaps a repro, e.g. what library, what code exactly, etc.

The error message is uninformative. clojure.lang.ExceptionInfo: babashka.ffi: cannot load library: <PATH> (bare names also searched in [ ... ]) ... The library is a personal one, a vector of all primes < 1e8. Useful for math problems, educational not research. On my system it's ~/.local/lib/libprimev.so . I can't imagine the raw data being useful for diagnosis, but I could post (gist?) primev.h .

Can you please provide the code you used to load this library?

(ffi/load-library "/home/jdj/.local/lib/libprimev.so") after requiring ffi, of course

can you test this:

(require '[babashka.ffi :as ffi])
(ffi/load-library "libc.so.6")

if that doesn’t work, you’re probably using the static binary

Same error modulo the library string

how did you install bb?

can you respond faster so I don’t have to context switch all the time? ;)

(kinda of a rude question of me)

The install script. I prefer bleeding edge. Sorry . Slow

can you post the output of:

file "$(command -v bb)"

Guessing you wanted . It is statically linked

Reading off laptop screen typing on phone

Script from babashka-dev-builds

have you updated the script?

you should use the latest script, it’ll get you the dynamic bb

No worries on "rude". Appreciate response. Not recently

Will do. Thanks

ok let me know when it works. I’d be delighted to learn how people are using ffi

Dynamic was the trick. I've successfully read 10 primes into a Clojure vector in the REPL. Need to rethink some things to port my JNA code, but I've started. Many thanks for your help.

One last thot: babashka.ffi is a joy to use. Honestly, I didn't stress it. I ported my simple primes.clj from JNA to ffi in a couple of hours at most. Extra benefit is that I can run & test the code with bb without the JVM slowing things down. Great fun!