echtvar icon indicating copy to clipboard operation
echtvar copied to clipboard

static binary

Open jianshu93 opened this issue 1 year ago • 6 comments

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

jianshu93 avatar Sep 01 '22 04:09 jianshu93

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.

brentp avatar Sep 01 '22 17:09 brentp

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

jianshu93 avatar Sep 01 '22 20:09 jianshu93

Did you see this: https://github.com/erickt/rust-zmq#vendored-build

brentp avatar Sep 01 '22 20:09 brentp

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

jianshu93 avatar Sep 01 '22 21:09 jianshu93

since gcc -lfortran relies on libgfortran.so

jianshu93 avatar Sep 01 '22 21:09 jianshu93

you should be able to get ndarray-linalg built statically: https://crates.io/crates/ndarray-linalg/0.13.1-alpha.1

brentp avatar Sep 01 '22 21:09 brentp