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 上它运行良好。

4

1 回答 1

1

因此,如果您发现此问题并且代码可以在其他机器上运行,我找到了解决方案。使用标准脚本卸载 rustrustup self uninstall然后重新安装curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh,然后你应该会很好。

于 2021-12-10T22:13:23.750 回答