rust-sfml
rust-sfml copied to clipboard
Better documentation and support for finding native libs on windows
- [ ] Determine where the SFML libraries should be installed for each of the GNU and MSVC toolchains
- [ ] Document it
- [ ] Add support in the build scripts for detecting and using the libraries installed in these locations.
Additional things that can be done
- [ ] Document #137
Mentioning #165 for reference.
I just got a rust-sfml window running on Windows with MSVC. It was painful because the documentation for building sfml/csfml with CMake is pretty much nonexistent to begin with.
Apparently, CSFML needs to be built as dynamic libraries, but use SFML as static libraries. So this is what I did, ending up with the following:
- sfml-XXX-s.lib files
- csfml-XXX.lib files
- csfml-XXX-2.dll files
I had to rename the sfml-XXX-s.lib to remove the "-s" suffix from the name, because this crate wants the clean name. I don't know if this suffix is something peculiar to the CMake build of SFML or what.
But, thinking about it more... if CSFML are DLLs containing a statically linked SFML, and the rust-sfml crate only interfaces with CSFML, then rust-sfml should not need to link with SFML at all, since it does not use it. Is this correct?
But, thinking about it more... if CSFML are DLLs containing a statically linked SFML, and the rust-sfml crate only interfaces with CSFML, then rust-sfml should not need to link with SFML at all, since it does not use it. Is this correct?
This might be true on windows, you could test it if you have the time. It isn't true on linux, where csfml links to sfml dynamically. Actually, it also works on Linux without linking against SFML. Now I'm not actually sure why we link to SFML.
In the long term, I'm planning to skip CSFML entirely, and use bindgen to bind directly to SFML, but I don't know yet what will come of that.
Hi. I have problem.
SFML 2.4.0 CSFML 2.4.0 32bit
E:\Users\Admin\projects\rust-sfml> cargo build --verbose Fresh bitflags v1.0.1 Fresh sfml-build v0.2.0 (file:///E:/Users/Admin/projects/rust-sfml/ffi/sfml-build) Fresh csfml-system-sys v0.4.0 (file:///E:/Users/Admin/projects/rust-sfml/ffi/csfml-system-sys) Fresh csfml-window-sys v0.4.0 (file:///E:/Users/Admin/projects/rust-sfml/ffi/csfml-window-sys) Fresh csfml-audio-sys v0.4.0 (file:///E:/Users/Admin/projects/rust-sfml/ffi/csfml-audio-sys) Fresh csfml-graphics-sys v0.4.0 (file:///E:/Users/Admin/projects/rust-sfml/ffi/csfml-graphics-sys) Compiling sfml v0.14.0 (file:///E:/Users/Admin/projects/rust-sfml) Running `rustc --crate-name sfml src\lib.rs ...
... error: linking with link.exe failed: exit code: 1181
... error: Could not compile sfml.
CSFML_HOME and SFML_HOME is fine.
other msvc c++ projects with sfml work fine with 32bit.
...
SFML 2.4.0 CSFML 2.4.0 64bit
It work, but how i can create static 32 bit project?
So it should be possible to skip the reference to sfml libraries in windows only? Can that be checked in the various build.rs ffi files that emit both libraries (or the sfml-build lib.rs file itself)? (I don't know about that stuff, learning as I go)
So it should be possible to skip the reference to sfml libraries in windows only? Can that be checked in the various build.rs ffi files that emit both libraries (or the sfml-build lib.rs file itself)? (I don't know about that stuff, learning as I go)
Yes, this should be possible using build scripts. One could check the value of CARGO_CFG_TARGET_OS, and do something different if it's windows.
I just wanted to document some differences I found between what I had to do and what was in the wiki.
For reference, I'm on 64-bit Windows 10, with rustc 1.27.2. And since I followed the installation instructions in the second edition of the Rust book, I'm using MSVC, not GCC.
- there were no
*.afiles, only*.lib - the path for the
*.libfiles was%UserProfile%\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib - I also needed to copy
openal32.dllfromSFML\binto get the pong example to run (I assume it's a dependency for SFML audio module).
For anyone coming across this issue, there's a wiki entry which worked perfectly for me: https://github.com/jeremyletang/rust-sfml/wiki/Windows And I was too blind to find it at first, so I'm putting this here in case someone else stumbles across this again.