This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-07-16
Channels
- # announcements (3)
- # babashka (25)
- # beginners (71)
- # calva (18)
- # clj-kondo (52)
- # cljs-dev (94)
- # cljsrn (12)
- # clojure (33)
- # clojure-europe (52)
- # clojure-nl (2)
- # clojure-uk (27)
- # clojurescript (18)
- # clojureverse-ops (4)
- # datomic (64)
- # deps-new (27)
- # depstar (5)
- # events (5)
- # fulcro (5)
- # graalvm (12)
- # graalvm-mobile (82)
- # helix (2)
- # introduce-yourself (1)
- # juxt (5)
- # lsp (10)
- # malli (7)
- # missionary (1)
- # off-topic (41)
- # pathom (69)
- # pedestal (6)
- # re-frame (4)
- # reagent (8)
- # releases (9)
- # remote-jobs (8)
- # shadow-cljs (3)
- # sql (46)
- # tools-deps (44)
- # uncomplicate (1)
- # vim (83)
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 os.name=Mac 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: https://github.com/mageddo/graalvm-examples/tree/59f1f1bf09894681edfddaa100b4504770ad0685/sqlite There's also a babashka sqlite pod, https://github.com/babashka/pod-babashka-go-sqlite3 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 https://github.com/BrunoBonacci/graalvm-clojure, so if you do find a working setup, it would be great to have it added to the list.
@chandru89new the clojure-lsp project uses sqlite and compiles it with graalvm native. /cc @ericdallo
@chandru89new I needed to do some hacks to make it work with clojure-lsp: I created this jar with some JNI fixes: https://github.com/ericdallo/sqlite-jni-graal-fix Check how clojure-lsp uses it here: https://github.com/clojure-lsp/clojure-lsp/blob/master/graalvm/native-unix-compile.sh
Check the other files as well:https://github.com/clojure-lsp/clojure-lsp/tree/master/resources/META-INF/native-image/clojure-lsp/clojure-lsp
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 (https://github.com/clojure-lsp/clojure-lsp/tree/master/resources/META-INF/native-image/clojure-lsp/clojure-lsp) … 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