linfa: Cargo run failed: Undefined symbols for architecture x86_64
I followed LinearRegression example and found err on cargo run
Code:
use linfa::prelude::SingleTargetRegression;
use linfa::traits::{Fit, Predict};
use linfa_linear::LinearRegression;
fn main() {
let dataset = linfa_datasets::diabetes();
let model = LinearRegression::default().fit(&dataset).unwrap(); # the error seems happen on this line
pred = model.predict(&dataset);
pred.r2(&dataset).unwrap();
}
Err output:
= note: Undefined symbols for architecture x86_64:
"_dgelsd_", referenced from:
lapack::dgelsd::h78796e3523b23ad8 in liblax-5505ca61a5fbc67a.rlib(lax-5505ca61a5fbc67a.lax.d19e9304-cgu.2.rcgu.o)
"_cblas_sdot", referenced from:
ndarray::linalg::impl_linalg::_$LT$impl$u20$ndarray..ArrayBase$LT$S$C$ndarray..dimension..dim..Dim$LT$$u5b$usize$u3b$$u20$1$u5d$$GT$$GT$$GT$::dot_impl::h7adddea61e00d52a in rust_ds-fc4af6c90afa881c.4mtkwkgjvot8wzn2.rcgu.o
"_cblas_ddot", referenced from:
ndarray::linalg::impl_linalg::_$LT$impl$u20$ndarray..ArrayBase$LT$S$C$ndarray..dimension..dim..Dim$LT$$u5b$usize$u3b$$u20$1$u5d$$GT$$GT$$GT$::dot_impl::h7adddea61e00d52a in rust_ds-fc4af6c90afa881c.4mtkwkgjvot8wzn2.rcgu.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
OS: Mac Catalina v10.15.7 Rust: rustc 1.58.1
I have try cargo clean but still can’t fix the issue
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (1 by maintainers)
Turns out
intel-mkl-staticdoesn’t work on MacOS because they didn’t package the crate with a prebuilt MacOS library. You either need to install the Intel BLAS library yourself and useintel-mkl-systemor trynetlib-static. Alternatively you can wait for #147 to be resolved forlinfa-linear, which should happen before the next big release. That way you won’t need to depend on an external BLAS library.How do you compile your example? Make sure you are linking properly against BLAS/LAPACK library using appropriate linfa feature (maybe ‘linfa/intel-mkl-static’ in your case, may take several minutes).