Fork me on GitHub

Hi, I asked a question on #clojure and was pointed in this channel’s direction. So I’m trying to compile a small clj file that makes use of sqlite via `org.xerial/sqlite-jdbc` … All works good as long as I’m in the REPL and running it through clj. I compile the file into a binary through GraalVM native-image utility. It compiles fine but when I run, I get this issue:

Caused by: java.lang.Exception: No native library is found for and os.arch=x86_64. path=/org/sqlite/native/Mac/x86_64
I’m completely new to Clojure (and have no knowledge of Java/JDBC etc) so wondering if anyone has compiled a clj+sqlite to binary and got it to work .. and if yes, how?


It looks like someone was able to get it to work with java: There's also a babashka sqlite pod, I've never used the pod stuff before, but it seems like that might be a possible way to use sqlite.


I don't see anything that looks like sqlite listed under, so if you do find a working setup, it would be great to have it added to the list.

👍 3

@chandru89new the clojure-lsp project uses sqlite and compiles it with graalvm native. /cc @ericdallo

👍 3

@chandru89new I needed to do some hacks to make it work with clojure-lsp: I created this jar with some JNI fixes: Check how clojure-lsp uses it here:


thank you. i will take a look!


Hi Eric. I’ve been trying to replicate your method to get this clj+sqlite to compile and work. But clearly I’m out of depth and would appreciate any help: • I notice that you use deps.edn and clojure command instead of lein and this was an intentional migration at clojure-lsp. Does this have any effect on the sqlite issue? • I added your sqlite-jni-graal-fix to my project but after looking at a few repos and examples, I’m unable to figure out how/where to add and use the configuration files you have in your other link ( … any pointers for this? • Also, any benefit of going deps.edn over lein and project.clj?


I know you must be busy so thank you very much for taking time to even answer my initial query! 🙂


• Clojure-lsp used to work with lein and Graalvm, but the Uber jar generated from lein started to not work for some weird reason, and at the time I red it was a issue on how Leon generate the jar, that's one of the reasons I changed to deps.edn • To make that lib work, that deps needs to be on your generated jar that you will compile with Graalvm, so my suggestion is to add a profile to lein that would add that deps and then generate the jar with it like: lein +with-profiles=native uberjar • Besides that issue with lein, I prefer deps.edn to be simpler configuration edn, faster repl startup, and probably replace lei n soon IMO


Also, make sure you configure your reflect-config.json jni json and etc, IMO the best way to configure that is to add that to the resources folder META-INF like I did to clojure-lsp, following that convention Graalvm should pick that config during compilation


thank you very much! I'll try this.