如何修复 macOS 上的错误"couldn't load codegen backend"?



main.rs:

fn main() {
println!("Hello world!");
}
$ rustc main.rs:
error: couldn't load codegen backend "/usr/local/lib/rustlib/i686-apple-darwin/codegen-backends/librustc_codegen_llvm-llvm.dylib": "dlsym(RTLD_DEFAULT, CFURLConnectionCreateWithProperties): symbol not found"

我使用的是通过rustup安装的带有Rust 1.30.1的macOS 10.11.6。gcc是CCD_ 1。

我在x86上的Gentoo系统上遇到过同样的问题。出于某种原因,codegen库已安装到

/usr/lib/rust-1.34.2/rust-1.34.2/rustlib/i686-unknown-linux-gnu/codegen-backends

注意重复的rust-1.34.2目录。

我的解决方案是从预期的位置符号链接目录;您必须使用root权限:

# cd /usr/lib/rust-1.34.2/rustlib/i686-unknown-linux-gnu/
# ln -s ../../rust-1.34.2/rustlib/i686-unknown-linux-gnu/codegen-backends .

当安装新版本的Rust时,您可能需要重复此操作。

相关内容

最新更新