How do I build a binary file that I can ship to users? That is, to build a statically linked application using
magic run mojo build myfile.mojo -o myapp
Currently, it looks like the paths to the libraries are hardcoded in the binary file. If I (i) move the location in which myapp was built or (ii) distribute the binary file, I get the error:
error while loading shared libraries: libKGENCompilerRTShared.so: cannot open shared object file: No such file or directory
Any ideas how to bundle all the libraries with my binary file?
Thanks for reaching out! Do you perhaps have some more concrete pointers? I did find the foreign functions interface, if that’s what you had in mind , but it is unclear to me how to move forward.
Ill ping you there’s someone else on the forum looking into C and C++ interoperability with Mojo. It kind of has underlying applications in this use case
Mojo does not currently support static linking. For now, users MUST use magic to run Mojo applications. This comes from a requirement to link with cpython, which doesn’t support musl particularly well, for the python interop features. Modular is aware that this is a strong desire for some users, like you and me, who are building pure mojo applications.
In the mean time, is there a way to have mojo link the libraries with a relative, rather than absolute, path? That would allow me to ship the entire .magic/envs directory as a temporary solution, I think.
I do not believe that there is. Mojo is currently mostly built around people who are going to have the dev tooling installed, or docker where you might as well use magic to set things up.