Naive question about static linking
I have a project (github mdxtoc/qtpi) which uses zarith. Many thanks for zarith, by the way. I distribute my program to not very many users on macOS, Windows and Linux. But some of these not very many complain, because along with my program they have to load libgmp, and they don't see themselves as system administrators. Hoping to make their lives easier I thought I'd static link libgmp into my program.
But that's not easy. On macOS at least it's really quite difficult: you can't use the -static flag when loading, and the -lgmp flag isn't issued by me but as a side effect of loading the zarith package. So I can't see how to insert -l
I came across this very useful website https://ocamlpro.com/blog/2021_09_02_generating_static_and_portable_executables_with_ocaml which tells me to find out all the flags used when loading, and copy them, changing the -lgmp one. That might well work, but I'd rather not if there's a simpler way, because of the maintenance problems it would introduce.
I thought of temporarily renaming the dynamic library so that -lgmp could only see the static version, but I'm scared to try that. I can't make a directory containing only the static library, because zarith also issues the -L flag which points to the libgmp directory.
So that's two bad ideas (three, if you count -static). Is there a better idea?
Static linking of libraries is becoming a challenge, not just for Zarith, not just for OCaml programs in general, but even for programs written entirely in C or C++... Right now I have no better suggestion to offer than those on the OCamlPro blog.
Thanks for replying. I’ll have to try it …
Sent from my iPhone
On 5 Sep 2022, at 10:30, Xavier Leroy @.***> wrote:
Static linking of libraries is becoming a challenge, not just for Zarith, not just for OCaml programs in general, but even for programs written entirely in C or C++... Right now I have no better suggestion to offer than those on the OCamlPro blog.
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.