Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error LNK1181: cannot open input file 'SDL2.lib' #391

Open
aekobear opened this issue May 30, 2017 · 7 comments
Open

fatal error LNK1181: cannot open input file 'SDL2.lib' #391

aekobear opened this issue May 30, 2017 · 7 comments

Comments

@aekobear
Copy link

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.

@aekobear
Copy link
Author

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.

@PengBain
Copy link

help, where the path of sdl2 be replaced

@clemarescx
Copy link

I had the same problem and fixed it by following and adapting the instructions on the README.md of the SDL2 bindings crate:

  1. Download mingw development libraries from
    http://www.libsdl.org/ (SDL2-devel-2.0.x-mingw.tar.gz).
  2. 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.

  1. 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,

  1. 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?

@mispon
Copy link

mispon commented Jan 1, 2021

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

@manuliner
Copy link

On Win 10 i run in this issue. reading docs of rust sdl helped

https://github.com/Rust-SDL2/rust-sdl2#windows-msvc

@sauntheninja2
Copy link

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

@ebaerwald
Copy link

ebaerwald commented Jan 2, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants