fatal error LNK1181: cannot open input file 'SDL2.lib'
i get this error when i run cargo build in the main project directory on windows 10. i assume i'm getting this error because i don't have SDL2 on my computer, but SDL for Windows is a .dll, not a .lib. and even then, i wouldn't know where to put the file so piston can find it.
for what it's worth, i "fixed" the problem by replacing sdl2 with glutin wherever it appeared. all examples work for me on win10 with glutin.
help, where the path of sdl2 be replaced
I had the same problem and fixed it by following and adapting the instructions on the README.md of the SDL2 bindings crate:
- Download mingw development libraries from http://www.libsdl.org/ (SDL2-devel-2.0.x-mingw.tar.gz).
- Unpack to a folder of your choosing (You can delete it afterwards).
Since I use the x86_64-pc-windows-msvc toolchain, i downloaded SDL2-devel-2.0.*-VC.zip instead.
- Copy all lib files from SDL2-devel-2.0.x-mingw\SDL2-2.0.x\x86_64-w64-mingw32\lib to: (for Rust 1.6 and above) C:\Program Files\Rust\lib\rustlib\x86_64-pc-windows-gnu\lib (for Rust versions 1.5 and below) C:\Program Files\Rust\bin\rustlib\x86_64-pc-windows-gnu\lib or to your library folder of choice, and ensure you have a system environment variable of LIBRARY_PATH = C:\your\rust\library\folder For Multirust Users, this folder will be in C:\Users\{Your Username}\AppData\Local\.multirust\toolchains\{current toolchain}\lib\rustlib\x86_64-pc-windows-gnu\lib
In my case, I copied all x64 *.lib files in the archive to
C:\...\.multirust\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\
Finally,
- Copy SDL2.dll from SDL2-devel-2.0.x-mingw\SDL2-2.0.x\x86_64-w64-mingw32\bin into your cargo project, right next to your Cargo.toml.
For me, the SDL2.dll was in the x64 folder with the three *.lib files. I had to copy it next to the .toml file for each example that had a linker problem (cube.rs and user_input.rs).
Somehow this seems like a bandaid solution. Is it not possible to install SDL2 in one place for all projects to refer to?
In my case I copied all libs files to:
C:\Users\Username\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\
and SDL2.dll right next to my Cargo.toml
It's work fine! Huge thx to @clemarescx
On Win 10 i run in this issue. reading docs of rust sdl helped
https://github.com/Rust-SDL2/rust-sdl2#windows-msvc
On Win 10 i run in this issue. reading docs of rust sdl helped
https://github.com/Rust-SDL2/rust-sdl2#windows-msvc
Thanks this worked
Thank you all 😊 I downloaded the lib files from the SDL2-devel-2.0.*-VC.zip package and moved them into the C:\Users\Username\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib\ folder. It works without moving the .dll file next to the Cargo.toml file. The way @clemarescx provided works for all libraries which are not included in the standard libraries from rust.