• 當前位置:首頁 > IT技術 > Windows編程 > 正文

    Bevy的Windows環境設置
    2022-05-29 22:45:23

    Bevy的環境具有特殊的依賴,不正確配置編譯將會有各種奇葩的報錯。

    0. 編譯環境

    OS:Windows11 Microsoft Windows [版本 10.0.22000.675]
    Rust版本:rustup nightly
    Bevy版本:0.7

    ?

    1. 安裝依賴的Windows c編譯器和開發SDK

    Bevy必須使用VS2019版本的c編譯器,其他版本會出問題,你可以通過vs2019安裝,也可以通過MSbuild2019安裝

    VS2019

    關鍵安裝2個組件:

    ??1. c編譯器:MSVC v142 - VS 2019 C++ x64/x86生成工具

    ??2. SDK:自己操作系統對應SDK,比如我的是 Windows 11 SDK(10.0.22000.0)

    ?

    ?

    2.? 安裝Rust Night版本,配置cargo代理

    https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe

    curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

    2.0 安裝GNU Windows編譯器

    如果不想費事安裝Visual Studio或者MSBuild工具,可以使用Linux的GNU工具鏈,其實就是安裝一個rust版的mingw。

    rustup toolchain install stable-x86_64-pc-windows-gnu
    rustup default stable-x86_64-pc-windows-gnu

    2.1 安裝rustup night版本

    rustup install nightly
    rustup default nightly
    rustc --version

    2.2 cargo 鏡像配置

    C:Usersxxx.cargoconfig 文件

    [source.crates-io]
    registry = "https://github.com/rust-lang/crates.io-index"
    replace-with = 'tuna'
    
    # 清華大學
    [source.tuna]
    registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
    
    # 上海交通大學
    [source.sjtu]
    registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
    
    # rustcc社區
    [source.rustcc]
    registry = "git://crates.rustcc.cn/crates.io-index"

    2.3 編譯加速

    cargo install -f cargo-binutils
    rustup component add llvm-tools-preview

    3.? bevy工程配置

    3.1 工程root目錄/.cargo/config.toml

    [target.x86_64-pc-windows-msvc]
    #linker = "rust-lld.exe"
    rustflags = ["-Zshare-generics=off"]

    注意 linker是注釋掉的 要不然會有報錯

    code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN

    Building the tutorial code with bevy/dynamic on Windows 10 raises error · Issue #2006 · bevyengine/bevy · GitHub

    3.2 工程依賴配置

    工程root目錄/target/Cargo.toml

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

    ?

    本文摘自 :https://www.cnblogs.com/

    開通會員,享受整站包年服務
    国产呦精品一区二区三区网站|久久www免费人咸|精品无码人妻一区二区|久99久热只有精品国产15|中文字幕亚洲无线码