echtvar
echtvar copied to clipboard
static binary
Hello Echtvar team,
Without too many experience in Rust, how do you make it completely static without relying on gcc compiling libraries such as libstdc++.so, when some of the dependencies/crates are rust binding to c/c++ libraries. like OpenBLAS, your case htslib?
Thanks,
Jianshu
Hi, I use:
cargo build --all --target x86_64-unknown-linux-gnu --release
with:
[build]
rustflags = ["-C", "target-feature=+crt-static"]
in .cargo/config
That seems to work for most users AFAICT.
I have dependencies like rust-zmq and ndarray-linalg crate, which relies on libc.so and libgfortran.so and libopenblas.so as backend support. No idea how to remove the dynamic library link requirements. I have a failure after trying, related to dynamic open of zmq requires dynamic link.
Jianshu
Did you see this: https://github.com/erickt/rust-zmq#vendored-build
Yes!use vendered,not crt-static,it works.
The openblas backend is the main problem,openblas itself can be statically linked but gfortran.so cannot.
Jianshu
since gcc -lfortran relies on libgfortran.so
you should be able to get ndarray-linalg built statically: https://crates.io/crates/ndarray-linalg/0.13.1-alpha.1