ruabmbua / enet-sys

Raw rust bindings to the enet C library
MIT License
19 stars 14 forks source link

Doesn't compile on Windows #5

Closed tzaeru closed 6 years ago

tzaeru commented 6 years ago

Hi,

Tried to compile with rustc 1.26.0 and clang version 6.0.0.

I.. Wont paste the error here, since it's 22 megabytes: https://www.tzaeru.com/p/output.txt

I've absolutely no idea how to approach fixing this! 😄

ruabmbua commented 6 years ago

I`ll download the error message. Will be done in 20 minutes :-P.

ruabmbua commented 6 years ago

Can you try with rust 1.26.1? Because that is working for me.

tzaeru commented 6 years ago

Same errors; error[E0277]: `_IMAGE_LINENUMBER__bindgen_ty_1` doesn't implement `std::fmt::Debug And [u8; 40]` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug

ruabmbua commented 6 years ago

I have a hard time reproducing your problem. Can you give me some information about your development platform and your current project setup?

E.g.:

and

You can also try to git clone https://github.com/ruabmbua/enet-sys.git, cd enet-sys, and cargo test the crate? If it can build on its own, then you probably have a problem with your project setup.

When it is really a windows problem, you probably have to ask someone else. I have lots of experience cross compiling from linux to windows, but I never touched a windows machine for the last couple of years.

tzaeru commented 6 years ago

cargo test for enet-sys resulted in:

error[E0277]: `_IMAGE_LINENUMBER__bindgen_ty_1` doesn't implement `std::fmt::Debug`
     --> C:\Users\tzaeru\Documents\enet-sys\target\debug\build\enet-sys-85aa5d215803b1f0\out/bindings.rs:51827:5
      |
51827 |     pub Type: _IMAGE_LINENUMBER__bindgen_ty_1,
      |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `_IMAGE_LINENUMBER__bindgen_ty_1` cannot be formatted using `:?`; add `#[derive(Debug)]` or manually implement `std::fmt::Debug`
      |
      = help: the trait `std::fmt::Debug` is not implemented for `_IMAGE_LINENUMBER__bindgen_ty_1`
      = note: required because of the requirements on the impl of `std::fmt::Debug` for `&_IMAGE_LINENUMBER__bindgen_ty_1`
      = note: required for the cast to the object type `std::fmt::Debug`

error[E0277]: `[u8; 40]` doesn't implement `std::fmt::Debug`
      --> C:\Users\tzaeru\Documents\enet-sys\target\debug\build\enet-sys-85aa5d215803b1f0\out/bindings.rs:114819:5
       |
114819 |     pub __bindgen_padding_0: [u8; 40usize],
       |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `[u8; 40]` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug`
       |
       = help: the trait `std::fmt::Debug` is not implemented for `[u8; 40]`
       = note: required because of the requirements on the impl of `std::fmt::Debug` for `&[u8; 40]`
       = note: required for the cast to the object type `std::fmt::Debug`

error: aborting due to 2 previous errors

Bindgen requires clang to analyze C/C++ headers. LLVM does compile for Windows and they actually give a pre-built binary here: http://releases.llvm.org/download.html

Windows version is 10, latest updates.

Clang --version data is:

clang version 6.0.0 (tags/RELEASE_600/final)
Target: x86_64-pc-windows-msvc
Thread model: posix

Rust toolset chain is stable-x86_64-pc-windows-msvc, currently rustc is 1.26.1, cargo is 1.26.0.

I had some other bizarre problems (for which I blame Windows without reservation), like when I tried changing compiler tooling around a bit. If I use Visual Studio Developer Prompt to have Visual Studio and MSBuild tools in PATH, then enet doesn't build as part of enet-sys because cmake can't find a C or C++ compiler.. ..but when I cloned enet directly, and tried building it, cmake generated correct build solution that worked fine. But that might be unrelated to this.

I'm admittedly not too much into Windows dev stuff either, even if I use Windows on my desktop. Though, might it be possible to provide pre-generated bindings as part of enet-sys itself? And might this be a bindgen bug?

ruabmbua commented 6 years ago

Maybe try downgrading the version to enet-sys = "0.1.4" in your Cargo.toml.

I think this one is handwritten by me (I can`t really remember), so no bindgen involved. Also the crate includes prebuilt static libraries (if you can trust me) for these platforms:

Edit: you have to switch to the rust windows-gnu toolchain for it to work

ruabmbua commented 6 years ago

I used to mess around with windows 2 years back, but already forgot everything... Im glad, that I am on Linux :P.

tzaeru commented 6 years ago

Hmm, that says

thread 'main' panicked at 'Target not supported.', C:\Users\tzaeru\.cargo\registry\src\github.com-1ecc6299db9ec823\enet-sys-0.1.4\src/build.rs:9:14

And yeah, tbh I often code on my Linux server and just connect remotely to it to code. It's just a bit annoying with Rust as if I use Sublime Text remotely, it wont be able to show the errors in the editor. And I make a lot of errors with Rust. The real solution would be to finally learn to use vim or emacs properly.

ruabmbua commented 6 years ago

Target not supported -> the old version only supports GNU-ABI not MSVC-ABI

rustup install stable-gnu
rustup default stable-gnu
tzaeru commented 6 years ago

Yup, works with 0.1.4, thanks!

I guess this ticket should be left open? I might at some point poke bindgen people if they knew what's up.

ruabmbua commented 6 years ago

Okay, I`ll leave it open.

spearman commented 6 years ago

What prevents using the msvc toolchain? I usually develop on Linux but would like to distribute Windows application using enet. From my understanding using the gnu toolchain makes this impossible?

kroltan commented 6 years ago

No, @spearman, you can use the GNU toolchain on Windows just fine, and successfully build applications with it.

However, you'll be trading the support for MSVC libraries for GNU libraries. That is, Windows-specific pre-compiled libraries likely won't work. That being said, Rust libraries will still work with either one, since they are compiled with your project and thus will use whichever ABI you choose.

ruabmbua commented 6 years ago

PR merged, thanks @spearman .