jeremyletang / rust-sfml

SFML bindings for Rust
Other
639 stars 88 forks source link

Support for static linking on Windows and Linux #290

Closed arm32x closed 2 years ago

arm32x commented 2 years ago

This pull request adds support for statically linking SFML for Windows (MSVC) and Linux, which can be activated by setting the SFML_STATIC environment variable.

This works by linking all dependencies of SFML into rust-sfml, which is the correct way to do static linking according to the SFML FAQ.

I have used this successfully to build statically-linked executables for the x86_64-pc-windows-msvc and x86_64-unknown-linux-gnu targets. No other targets have been tested and are not likely to work without further changes.

On Linux, SFML must be built from source with the BUILD_SHARED_LIBS CMake option set to false, since most SFML packages do not include static libraries.

crumblingstatue commented 2 years ago

Thank you, I'll take a closer look tomorrow!

crumblingstatue commented 2 years ago

Well.... This requires static libraries for all SFML deps to be present on the system, which is not the case on most systems, and sounds like a pain to prepare for the average user.

But since this doesn't affect dynamically linked SFML, I'm accepting this pull request.