slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
16.93k stars 566 forks source link

winit incorrectly reports unsupported platform #2506

Closed kivimango closed 1 year ago

kivimango commented 1 year ago

Hello ! I cant compile my slint app on Manjaro Linux:

error: The platform you're compiling for is not supported by winit
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:67:1
   |
67 | compile_error!("The platform you're compiling for is not supported by winit");
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved import `self::platform`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:26:15
   |
26 | pub use self::platform::*;
   |               ^^^^^^^^ could not find `platform` in `self`

error[E0432]: unresolved import `crate::platform_impl::PlatformIcon`
 --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/icon.rs:1:5
  |
1 | use crate::platform_impl::PlatformIcon;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `PlatformIcon` in `platform_impl`

error[E0433]: failed to resolve: could not find `DeviceId` in `platform_impl`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event.rs:789:33
    |
789 |         DeviceId(platform_impl::DeviceId::dummy())
    |                                 ^^^^^^^^ could not find `DeviceId` in `platform_impl`

error[E0433]: failed to resolve: could not find `WindowId` in `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:86:33
   |
86 |         WindowId(platform_impl::WindowId::dummy())
   |                                 ^^^^^^^^ could not find `WindowId` in `platform_impl`

error[E0433]: failed to resolve: could not find `Window` in `platform_impl`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:465:24
    |
465 |         platform_impl::Window::new(&window_target.p, self.window, self.platform_specific).map(
    |                        ^^^^^^ could not find `Window` in `platform_impl`

error[E0412]: cannot find type `OsError` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/error.rs:25:27
   |
25 |     error: platform_impl::OsError,
   |                           ^^^^^^^ not found in `platform_impl`
   |
help: there is an enum variant `crate::window::BadIcon::OsError`; try using the variant's enum
   |
25 |     error: crate::window::BadIcon,
   |            ~~~~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `OsError` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/error.rs:38:76
   |
38 |     pub(crate) fn new(line: u32, file: &'static str, error: platform_impl::OsError) -> OsError {
   |                                                                            ^^^^^^^ not found in `platform_impl`
   |
help: there is an enum variant `crate::window::BadIcon::OsError`; try using the variant's enum
   |
38 |     pub(crate) fn new(line: u32, file: &'static str, error: crate::window::BadIcon) -> OsError {
   |                                                             ~~~~~~~~~~~~~~~~~~~~~~

error[E0412]: cannot find type `DeviceId` in module `platform_impl`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event.rs:776:47
    |
776 | pub struct DeviceId(pub(crate) platform_impl::DeviceId);
    |                                               ^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `EventLoop` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:36:43
   |
36 |     pub(crate) event_loop: platform_impl::EventLoop<T>,
   |                                           ^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `EventLoopWindowTarget` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:47:34
   |
47 |     pub(crate) p: platform_impl::EventLoopWindowTarget<T>,
   |                                  ^^^^^^^^^^^^^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `PlatformSpecificEventLoopAttributes` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:57:50
   |
57 |     pub(crate) platform_specific: platform_impl::PlatformSpecificEventLoopAttributes,
   |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `platform_impl`

error[E0433]: failed to resolve: could not find `EventLoop` in `platform_impl`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:121:40
    |
121 |             event_loop: platform_impl::EventLoop::new(&mut self.platform_specific),
    |                                        ^^^^^^^^^ could not find `EventLoop` in `platform_impl`
    |
help: consider importing this struct
    |
10  | use crate::event_loop::EventLoop;
    |
help: if you import `EventLoop`, refer to it directly
    |
121 -             event_loop: platform_impl::EventLoop::new(&mut self.platform_specific),
121 +             event_loop: EventLoop::new(&mut self.platform_specific),
    |

error[E0412]: cannot find type `EventLoopProxy` in module `platform_impl`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/event_loop.rs:373:38
    |
373 |     event_loop_proxy: platform_impl::EventLoopProxy<T>,
    |                                      ^^^^^^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `VideoMode` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/monitor.rs:18:43
   |
18 |     pub(crate) video_mode: platform_impl::VideoMode,
   |                                           ^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `MonitorHandle` in module `platform_impl`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/monitor.rs:107:38
    |
107 |     pub(crate) inner: platform_impl::MonitorHandle,
    |                                      ^^^^^^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `VideoMode` in this scope
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:31:15
   |
31 |     Exclusive(VideoMode),
   |               ^^^^^^^^^ not found in this scope
   |
help: consider importing this struct
   |
1  | use crate::monitor::VideoMode;
   |

error[E0412]: cannot find type `MonitorHandle` in this scope
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/platform_impl/mod.rs:32:23
    |
32  |     Borderless(Option<MonitorHandle>),
    |                       ^^^^^^^^^^^^^
    |
   ::: /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/monitor.rs:106:1
    |
106 | pub struct MonitorHandle {
    | ------------------------ similarly named struct `RootMonitorHandle` defined here
    |
help: a struct with a similar name exists
    |
32  |     Borderless(Option<RootMonitorHandle>),
    |                       ~~~~~~~~~~~~~~~~~
help: consider importing this struct
    |
1   | use crate::monitor::MonitorHandle;
    |

error[E0412]: cannot find type `Window` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:45:39
   |
45 |     pub(crate) window: platform_impl::Window,
   |                                       ^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `WindowId` in module `platform_impl`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:73:47
   |
73 | pub struct WindowId(pub(crate) platform_impl::WindowId);
   |                                               ^^^^^^^^ not found in `platform_impl`

error[E0412]: cannot find type `PlatformSpecificWindowBuilderAttributes` in module `platform_impl`
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:110:50
    |
110 |     pub(crate) platform_specific: platform_impl::PlatformSpecificWindowBuilderAttributes,
    |                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not found in `platform_impl`

error[E0282]: type annotations needed
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/winit-0.28.1/src/window.rs:492:17
    |
492 |         builder.build(event_loop)
    |                 ^^^^^ cannot infer type of the type parameter `T` declared on the associated function `build`
    |
help: consider specifying the generic argument
    |
492 |         builder.build::<T>(event_loop)
    |                      +++++

Some errors have detailed explanations: E0282, E0412, E0432, E0433.
For more information about an error, try `rustc --explain E0282`.
error: could not compile `winit` due to 22 previous errors
warning: build failed, waiting for other jobs to finish...

Cargo.toml:

[dependencies]
slint = { git = "https://github.com/slint-ui/slint", default-features = false, features = ["compat-0-3-0", "renderer-winit-software"] }

[build-dependencies]
slint-build = { git = "https://github.com/slint-ui/slint" }

My project is in a workspace with another slint apps, and im having a hard time compiling slint apps, so every app must use the same slint version or it wont compile.

If i enable the default features in the Cargo.toml file, it compiles fine.

tronical commented 1 year ago

I think this error will go away if you add backend-winit to the features.

ogoffart commented 1 year ago

Yes, one need backend-winit OR, one of backend-winit-x11 or backend-winit-wayland.

Did you try to compile with backend-winit already? Assuming it works, please re-open or comment if you still get a compilation error

kivimango commented 1 year ago

Hello. Yes, it is fixed when im compiling with backend-winit feature. Thank you. However, im still confused how to choose/set backends/and or renderers even after i red the docs.

tronical commented 1 year ago

Sorry about that :-(. I wonder if we can improve the docs somehow. Which part is most confusing to you? Which part makes sense? :)