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

Better documentation and support for finding native libs on windows #138

Open
4 tasks
crumblingstatue opened this issue Oct 8, 2016 · 8 comments
Open
4 tasks

Comments

@crumblingstatue
Copy link
Collaborator

crumblingstatue commented Oct 8, 2016

  1. Determine where the SFML libraries should be installed for each of the GNU and MSVC toolchains
  2. Document it
  3. Add support in the build scripts for detecting and using the libraries installed in these locations.

Additional things that can be done

@crumblingstatue
Copy link
Collaborator Author

Mentioning #165 for reference.

@TheJare
Copy link
Contributor

TheJare commented Dec 30, 2017

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?

@crumblingstatue
Copy link
Collaborator Author

crumblingstatue commented Dec 31, 2017

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.

@lernrust
Copy link

lernrust commented Dec 31, 2017

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?

@TheJare
Copy link
Contributor

TheJare commented Dec 31, 2017

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)

@crumblingstatue
Copy link
Collaborator Author

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.

@metavee
Copy link

metavee commented Aug 25, 2018

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 *.a files, only *.lib
  • the path for the *.lib files was %UserProfile%\.rustup\toolchains\stable-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-msvc\lib
  • I also needed to copy openal32.dll from SFML\bin to get the pong example to run (I assume it's a dependency for SFML audio module).

@Kiiyya
Copy link

Kiiyya commented Dec 28, 2020

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.

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

No branches or pull requests

5 participants