编译bevy_dylib v0.5.0错误:与"cc"链接失败:退出状态:1



在刚升级到Monterey的Mac上,当我尝试cargo run一个微不足道的Bevy程序时,我得到了以下内容。我已经像这里和其他地方推荐的那样重新安装了XCode CLT。我试过摆弄一些cargo.yml,但没有成功。

Compiling bevy_dylib v0.5.0
error: linking with `cc` failed: exit status: 1
note: "cc" "-Wl,-exported_symbols_list,/var/folders/rp/lky8r76j5v5dk0rqg_yzk35w0000gn/T/rustcDYBmaq/list" 
"-m64" "-arch" "x86_64" <......... many pages of warnings>
ld: warning: object file (/Users/BWStearns/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy-glsl-to-spirv-0.2.1/build/osx/libSPIRV-Tools-opt.glsltospirv.a(const_folding_rules.cpp.o)) was built for newer macOS version (10.13) than being linked (10.7)
<many more pages of warnings>
"_CGDisplayCreateUUIDFromDisplayID", referenced from:
_$LT$winit..platform_impl..platform..monitor..MonitorHandle$u20$as$u20$core..cmp..PartialEq$GT$::eq::h541b069daf520ec9 in libwinit-4f8b93ad49cc21f8.rlib(winit-4f8b93ad49cc21f8.winit.355ded65-cgu.6.rcgu.o)
_$LT$winit..platform_impl..platform..monitor..MonitorHandle$u20$as$u20$core..cmp..Ord$GT$::cmp::h951d61f6bd1d7a5f in libwinit-4f8b93ad49cc21f8.rlib(winit-4f8b93ad49cc21f8.winit.355ded65-cgu.6.rcgu.o)
winit::platform_impl::platform::monitor::MonitorHandle::ns_screen::h3207f8aed4eae22f in libwinit-4f8b93ad49cc21f8.rlib(winit-4f8b93ad49cc21f8.winit.355ded65-cgu.6.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)

error: could not compile `bevy_dylib` due to previous error

cargo.yml是这样的:

[package]
name = "my_bevy_game"
version = "0.1.0"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
bevy = { version = "0.5.0", features = ["dynamic"] }

我刚从本周开始遇到这个。我确信这段代码在几周前编译得很好。如有任何帮助,我们将不胜感激。

main.rs看起来像

use bevy::prelude::*;
struct Person;
struct Name(String);
fn add_people(mut commands: Commands) {
commands.spawn().insert(Person).insert(Name("Elaina Proctor".to_string()));
commands.spawn().insert(Person).insert(Name("Renzo Hume".to_string()));
commands.spawn().insert(Person).insert(Name("Zayna Nieves".to_string()));
}
fn greet_people(query: Query<&Name, With<Person>>) {
for name in query.iter() {
println!("hello {}!", name.0);
}
}
pub struct HelloPlugin;
impl Plugin for HelloPlugin {
fn build(&self, app: &mut AppBuilder) {
app.add_startup_system(add_people.system())
.add_system(greet_people.system());
}
}
fn main() {
App::build()
.add_plugins(DefaultPlugins)
.add_plugin(HelloPlugin)
.run();
}

更新:

这肯定是我机器上的环境问题,因为在另一台macbook上,它运行得很好。

因此,如果您发现这个问题并且代码在其他机器上运行,我发现了一个解决方案。用rustup self uninstall卸载rust,然后用标准脚本curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh重新启动,这样你就应该很好了。

相关内容

最新更新