rust linux下使用openblas-src时免编译大法
程序需要用到nalgebra-lapack,而它又依赖openblas,每次运行需要编译openblas-src,之后需要动态链接,实在太麻烦了。
静态链接才是王道,可以快速丢到其他服务器上去计算。
cargo.toml内容:
[dependencies]
nalgebra = "0.32.2"
approx = "0.5.1"
libc = "0.2.142"
[dependencies.nalgebra-lapack]
version = "0.24.0"
default-features = false
features = [ "openblas" ]
[dependencies.openblas-src]
version = "0.10.8"
features = ["static","system","cache"]
指定libopenblas.a的 -L参数的方法,试了好多办法,包括config.toml,rustc -- -L /lib64,都不灵。每次都报错:
could not find native static library `openblas`, perhaps an -L flag is missing?
最后还是这个命令靠谱:
RUSTFLAGS='-L /lib64' cargo build
或者release版本的:
RUSTFLAGS='-L /lib64' cargo build --release