![](/img/trans.png)
[英]Python lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyErr_ReplaceException
[英]Undefined symbol LAPACKE when importing Rust lib .so into Python
我正在嘗試使用ndarray
和ndarray-linalg
類的板條箱在 Rust 中創建一個簡單的 ML 庫,並稍后通過 ctypes 在 Python 中利用它。 在 Cargo.toml 中,我設置crate-type = ["cdylib"]
。 My projet is built and works just fine in Rust but when I tried to import the output.so file into Python, it generates an error OSError: /home/Project/Lib/regression_simple/target/debug/libregression_simple.so: undefined symbol: LAPACKE_dgetri
我安裝了所有 lapack 和 blas 必要的軟件包,可以在/usr/include/lapacke.h
中找到 lapacke.h
我似乎在網上找不到任何類似的問題。 當我編譯 Rust 庫時,我確實看到加載了 ndarray-linalg 的所有依賴項 package,所以我不知道這個問題來自哪里。
我的貨物.toml
[lib]
name = "regression_simple"
crate-type = ["cdylib"]
[dependencies]
ndarray = { version = "0.13.0", features = ["blas"] }
ndarray-linalg = { version = "0.12.0", features = ["openblas"] }
ndarray-rand = "0.11.0"
openblas-src = {version = "0.7", features = ["system"]}
rand = "0.7.3"
我在一個項目中遇到了這個問題,解決方案是指示 rustc 鏈接到lapacke
。
我在build.rs
文件中添加了以下內容。
fn main() {
println!("cargo:rustc-link-lib=dylib=lapacke");
}
一旦我這樣做了,我就不再得到未定義的符號錯誤。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.