Skip to content
runneypo edited this page Nov 17, 2022 · 13 revisions

NOTE: This article is severely outdated and needs to be updated.

The gist of setting up SFML on windows is to download the SFML version matching your toolchain from https://www.sfml-dev.org/download/sfml/2.5.1/, then extract it to a place of your liking, say, C:/Users/Me/Downloads/SFML.

Then you can set the following environment variables:

  • SFML_INCLUDE_DIR to C:/Users/Me/Downloads/SFML/include.
  • SFML_LIBS_DIR to C:/Users/Me/Downloads/SFML/lib.

You might need to log out and back in for environment variables to take effect.

This should let rust-sfml build correctly.

When you want to run your rust-sfml project, you should copy the .dlls inside C:/Users/Me/Downloads/SFML/bin to your projects target/debug or /target/release folder. Or possibly the working directory. I'm not sure if that's necessary.

=== EVERYTHING BELOW HERE IS SEVERELY OUTDATED ===

For GNU Toolchains

  • Download the CSFML and SFML zip files from the links at https://github.com/jeremyletang/rust-sfml#prerequisites
  • From within the extracted archives:
    • Copy the *.a files from CSFML\lib\gcc and SFML\lib to C:\Program Files\Rust stable 1.3\bin\rustlib\x86_64-pc-windows-gnu\lib
  • Build your project e.g. using cargo build --release
    • Copy the DLL files from CSFML\bin to target\release

For MSVC Toolchains

  • Download the archived precompiled Visual C++ SFML and CSFML libraries for SFML. Extract both zip files to a preferred location for libraries. i.e. D:\libs\x64\
  • Download LLVM
    • Set for path for user or users during install.
  • Set environment variables:
    • SFML_INCLUDE_DIR=D:\libs\x64\SFML-2.5.1\include
    • SFML_LIBS_DIR=D:\libs\x64\SFML-2.5.1\lib
  • From within the extracted archives:
    • Copy the *.lib files from CSFML\lib\msvc and SFML\lib to C:\Users\[USERNAME]\.rustup\toolchains\[RUST_TOOLCHAIN]\lib\rustlib\[MSVC_TOOLCHAIN]\lib
    • If you change Rust toolchains, make sure to copy the *.lib files to the new toolchain's directory as well.
  • Build your project
    • Copy the *.dll files from CSFML\bin to the working directory of your compiled executable (usually target\debug or target\release)
    • Note: You only need to copy the *.dll files that correspond to the rust-sfml modules you are using. e.g. copy csfml-graphics-2.dll if your code contains using sfml::graphics.

Note: If you cloned this repo to test the examples you need to copy the *.dll files from SFML\bin to target\debug\examples or target\release\examples. You only need to copy the *.dll files that correspond to the rust-sfml modules you are using. e.g. copy sfml-graphics-2.dll if your code contains use sfml::graphics.

Clone this wiki locally