bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
36.26k stars 3.58k forks source link

Linker error 1189 when building a clean project with dynamic linking enabled. #14930

Open Syst3mz opened 2 months ago

Syst3mz commented 2 months ago

Bevy version 0.14.1

The release number or commit hash of the version you're using.

Relevant system information

If you cannot get Bevy to build or run on your machine, please include:

What you did

According to the guide faster compile times can be achieved with dynamic linking. In search of that I enbled dynamic linking by adding the following to my cargo.toml: bevy = { version = "0.14.1", features = ["dynamic_linking"] }

What went wrong

error: linking with `link.exe` failed: exit code: 1189
  |
  = note: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\bin\\HostX64\\x64\\link.exe" 
"/DEF:C:X\\Local\\Temp\\rustcD8vSs4\\lib.def" 
"/NOLOGO" "X\\AppData\\Local\\Temp\\rustcD8vSs4\\symbols.o" 
"X\\target\\debug\\deps\\bevy_dylib-2b3dce39ee4b4c6f.bevy_dylib.90fed09237c39069-cgu.0.rcgu.o" 
"X\\target\\debug\\deps\\bevy_dylib-2b3dce39ee4b4c6f.asofsqsln0vum3sln60e977yj.rcgu.rmeta" 
"/LIBPATH:X\\target\\debug\\deps" 
"/LIBPATH:C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\atlmfc\\lib\\x64" 
"/LIBPATH:X\\target\\debug\\build\\blake3-01a454a5bf9a393f\\out" 
"/LIBPATH:C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\Tools\\MSVC\\14.37.32822\\atlmfc\\lib\\x64" 
"/LIBPATH:X\\target\\debug\\build\\blake3-01a454a5bf9a393f\\out" 
"/LIBPATH:X\\.cargo\\registry\\src\\index.crates.io-6f17d22bba15001f\\windows_x86_64_msvc-0.52.6\\lib" 
"/LIBPATH:X\\.rustup\\toolchains\\stable-x86_64-pc-windows-msvc\\lib\\rustlib\\x86_64-pc-windows-msvc\\lib" 
"X\\target\\debug\\deps\\libbevy_internal-f2c0e9e74a2f412f.rlib" 
"X\\target\\debug\\deps\\libbevy_winit-898010402dda6460.rlib" 
"X\\target\\debug\\deps\\libaccesskit_winit-d3ae1a99b1858887.rlib" 
"X\\target\\debug\\deps\\libaccesskit_windows-153a057c7ac4b847.rlib" 
"X\\target\\debug\\deps\\libaccesskit_consumer-b3d184f8d993ded8.rlib" 
"X\\target\\debug\\deps\\libimmutable_chunkmap-260bd013ad1732b9.rlib" 
"X\\target\\debug\\deps\\libwinit-b69c7b4ffa68fe01.rlib" 
"X\\target\\debug\\deps\\libunicode_segmentation-cfa1f6fa6d11c161.rlib" 
"X\\target\\debug\\deps\\libwindows_sys-d9454f84c4d72027.rlib" 
"X\\target\\debug\\deps\\libcursor_icon-bbf223cbee500960.rlib"
...
  = note: LINK : fatal error LNK1189: library limit of 65535 objects exceeded

X's are user path stuff, shouldn't be relevant but happy to reveal if needed.

SkiFire13 commented 2 months ago

The guide also has a big warning that on Windows you must enable the performance optimizations (i.e. set opt-level = 3 at least for dependencies) or you'll get a linker error like the one you reported. Did you do that?

The comment that posted the mediafire link is almost surely a spam bot given that today many different accounts spammed that same message, sometimes all at the same time.

ilyas-taouaou commented 1 week ago

I had that problem too following the dynamic_linking instructions but I fixed it by replacing -Zshare-generics=y with -Zshare-generics=n. for completeness sake here in my .cargo/config.toml

[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe"
rustflags = ["-Zshare-generics=n", "-Zthreads=0"]

and here is my profile settings in cargo.toml

[profile.dev]
opt-level = 1

[profile.dev.package."*"]
opt-level = 3

[profile.release]
# codegen-units = 1
# lto = "thin"

[profile.wasm-release]
inherits = "release"
opt-level = "s"
strip = "debuginfo"

Note am using rust-lld linker here so make sure you have that installed.