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

rust-sdl2 fails to compile with use-bindgen feature #961

Closed
ghost opened this issue Jan 18, 2020 · 7 comments · Fixed by #976
Closed

rust-sdl2 fails to compile with use-bindgen feature #961

ghost opened this issue Jan 18, 2020 · 7 comments · Fixed by #976

Comments

@ghost
Copy link

ghost commented Jan 18, 2020

I'm trying to add raw-window-handle #910 to rust-sdl2 which requires running bindgen to get the right bindings, but the build fails with a bunch of import errors in pixels.rs: https://gist.github.com/lmcgrath/8cc694479c63f8f6451b69eb08e6d7d8. The project builds fine without bindgen, so it looks like the references to the pixel format enum values needs to be updated (use sys::SDL_PixelFormatEnum::* instead of sys::*). Would I be ok to fix this myself?

@ghost
Copy link
Author

ghost commented Jan 19, 2020

Poking at this a bit, I think the existing bindgen files are out of date relative to what bindgen produces. I get a pretty large diff between the current sdl_bindings.rs and the one that bindgen produces.

@Cobrand
Copy link
Member

Cobrand commented Jan 20, 2020

There might be a new setting in bindgen that changes this behavior somehow. I'm not against modifying the sdl2-sys crate, but doing it only because of bindgen updated seems too little of an issue for such a breaking change. Remember that there are people that only depend on sdl2-sys.

If there is no other way then sure, but surely there is an explanation why the old bindings looks like what we have now, compared the newer version you are trying to generate.

@ghost
Copy link
Author

ghost commented Jan 20, 2020

I really only need the definition of the SDL_SysWMinfo struct to work across platforms. Would you be open to me adding platform-specific definitions to that struct?

@Cobrand
Copy link
Member

Cobrand commented Jan 21, 2020

I am open to platform-specific definitions, but I don't really understand how it's linked to this issue?

@ghost
Copy link
Author

ghost commented Jan 21, 2020

Maybe I’m doing something wrong running bindgen, rust-sdl2 itself doesn’t compile when it’s enabled, but pulling it in as a dependency with bindgen enabled it will compile 🤷‍♀️. I was just looking for an “easy” way to get the correct bindings generated for SDL_SysWMinfo.

I’ll submit a PR with the changes to the struct. 👍

@ghost ghost closed this as completed Jan 21, 2020
@lewisclement
Copy link
Contributor

I'm running into this exact problem. Using commit 144c483 @ #962 . Manually changing the pixel formats to SDL_PixelFormatEnum doesn't help either, still getting "Application not compiled with SDL 2.0". Both bundled and system, with and without bindgen. Using Ubuntu 18.04.

@DomWilliams0
Copy link

Same here on Arch Linux, using this as the dependency fails to compile with the very verbose errors.

sdl2 = {version = "^0.33", features = ["bundled", "use-bindgen", "use-pkgconfig"], optional = true}
   Compiling sdl2 v0.33.0
error[E0425]: cannot find value `SDL_PIXELFORMAT_UNKNOWN` in crate `sys`
    --> /home/dom/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.33.0/src/sdl2/pixels.rs:192:20
     |
192  |     Unknown = sys::SDL_PIXELFORMAT_UNKNOWN as i32,
     |                    ^^^^^^^^^^^^^^^^^^^^^^^
     | 
    ::: /tmp/testysdl/target/debug/build/sdl2-sys-2a0fa38873a99554/out/sdl_bindings.rs:5592:1
     |
5592 | pub const SDL_PIXELTYPE_UNKNOWN: _bindgen_ty_1 = _bindgen_ty_1::SDL_PIXELTYPE_UNKNOWN;
     | -------------------------------------------------------------------------------------- similarly named constant `SDL_PIXELTYPE_UNKNOWN` defined here
     |
help: a constant with a similar name exists
     |
192  |     Unknown = sys::SDL_PIXELTYPE_UNKNOWN as i32,
     |                    ^^^^^^^^^^^^^^^^^^^^^
help: possible candidate is found in another module, you can import it into scope
     |
1    | use sys::SDL_PixelFormatEnum::SDL_PIXELFORMAT_UNKNOWN;
     |

error[E0425]: cannot find value `SDL_PIXELFORMAT_INDEX1LSB` in crate `sys`
   --> /home/dom/.cargo/registry/src/github.com-1ecc6299db9ec823/sdl2-0.33.0/src/sdl2/pixels.rs:193:22
    |
193 |     Index1LSB = sys::SDL_PIXELFORMAT_INDEX1LSB as i32,
    |                      ^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `sys`
    |
help: possible candidate is found in another module, you can import it into scope
    |
1   | use sys::SDL_PixelFormatEnum::SDL_PIXELFORMAT_INDEX1LSB;
    |


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

Successfully merging a pull request may close this issue.

3 participants