I am trying to link a library against a local build of arpack. I have compiled arpack itself and I have it as a static binary. I then make this build.rs
<code>use std::env;
use std::path::Path;
fn main() {
// Get the path to the directory containing the Cargo.toml file (workspace root)
let workspace_root =
env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
// Define the path to the directory containing the native libraries relative to the workspace root
let lib_path = Path::new(&workspace_root).join("arpack-ng/build/");
println!("cargo:warning={}", lib_path.display());
// Print the instructions for Cargo to find the native libraries
println!("cargo:rustc-link-search=native={}", lib_path.display());
println!("cargo:rustc-link-lib=static=arpack");
}
</code>
<code>use std::env;
use std::path::Path;
fn main() {
// Get the path to the directory containing the Cargo.toml file (workspace root)
let workspace_root =
env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
// Define the path to the directory containing the native libraries relative to the workspace root
let lib_path = Path::new(&workspace_root).join("arpack-ng/build/");
println!("cargo:warning={}", lib_path.display());
// Print the instructions for Cargo to find the native libraries
println!("cargo:rustc-link-search=native={}", lib_path.display());
println!("cargo:rustc-link-lib=static=arpack");
}
</code>
use std::env;
use std::path::Path;
fn main() {
// Get the path to the directory containing the Cargo.toml file (workspace root)
let workspace_root =
env::var("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR not set");
// Define the path to the directory containing the native libraries relative to the workspace root
let lib_path = Path::new(&workspace_root).join("arpack-ng/build/");
println!("cargo:warning={}", lib_path.display());
// Print the instructions for Cargo to find the native libraries
println!("cargo:rustc-link-search=native={}", lib_path.display());
println!("cargo:rustc-link-lib=static=arpack");
}
This fails with this error:
<code> = note: /usr/bin/ld: /home/makogan/rust_never_engine/crates/algebra/target/debug/deps/algebra-8ab0fc9a1c48e81c.8q7c32k90oqy6djs87syi3nmg.rcgu.o: in function `algebra::eigen_decomposition::faer_arpack_symmetric_f64':
/home/makogan/rust_never_engine/crates/algebra/src/eigen_decomposition.rs:150:(.text._ZN7algebra19eigen_decomposition25faer_arpack_symmetric_f6417h42c779a97fe8f680E+0xa27): undefined reference to `dsaupd_c'
/usr/bin/ld: /home/makogan/rust_never_engine/crates/algebra/src/eigen_decomposition.rs:199:(.text._ZN7algebra19eigen_decomposition25faer_arpack_symmetric_f6417h42c779a97fe8f680E+0x2b7d): undefined reference to `dseupd_c'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
The following warnings were emitted during compilation:
warning: [email protected]: /home/makogan/rust_never_engine/crates/algebra/arpack-ng/build/
</code>
<code> = note: /usr/bin/ld: /home/makogan/rust_never_engine/crates/algebra/target/debug/deps/algebra-8ab0fc9a1c48e81c.8q7c32k90oqy6djs87syi3nmg.rcgu.o: in function `algebra::eigen_decomposition::faer_arpack_symmetric_f64':
/home/makogan/rust_never_engine/crates/algebra/src/eigen_decomposition.rs:150:(.text._ZN7algebra19eigen_decomposition25faer_arpack_symmetric_f6417h42c779a97fe8f680E+0xa27): undefined reference to `dsaupd_c'
/usr/bin/ld: /home/makogan/rust_never_engine/crates/algebra/src/eigen_decomposition.rs:199:(.text._ZN7algebra19eigen_decomposition25faer_arpack_symmetric_f6417h42c779a97fe8f680E+0x2b7d): undefined reference to `dseupd_c'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
The following warnings were emitted during compilation:
warning: [email protected]: /home/makogan/rust_never_engine/crates/algebra/arpack-ng/build/
</code>
= note: /usr/bin/ld: /home/makogan/rust_never_engine/crates/algebra/target/debug/deps/algebra-8ab0fc9a1c48e81c.8q7c32k90oqy6djs87syi3nmg.rcgu.o: in function `algebra::eigen_decomposition::faer_arpack_symmetric_f64':
/home/makogan/rust_never_engine/crates/algebra/src/eigen_decomposition.rs:150:(.text._ZN7algebra19eigen_decomposition25faer_arpack_symmetric_f6417h42c779a97fe8f680E+0xa27): undefined reference to `dsaupd_c'
/usr/bin/ld: /home/makogan/rust_never_engine/crates/algebra/src/eigen_decomposition.rs:199:(.text._ZN7algebra19eigen_decomposition25faer_arpack_symmetric_f6417h42c779a97fe8f680E+0x2b7d): undefined reference to `dseupd_c'
collect2: error: ld returned 1 exit status
= note: some `extern` functions couldn't be found; some native libraries may need to be installed or have their path specified
= note: use the `-l` flag to specify native libraries to link
= note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib)
The following warnings were emitted during compilation:
warning: [email protected]: /home/makogan/rust_never_engine/crates/algebra/arpack-ng/build/
I have compiled arpack, the file libarpack.a
exists under the path /home/makogan/rust_never_engine/crates/algebra/arpack-ng/build/
. So the library exists, and the build.rs is pointing to the correct location, why is cargo not linking it?