rust-windowing / winit

Window handling library in pure Rust

Home Page:https://docs.rs/winit/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOOB: unable to build example

andrewcollier-com-au opened this issue · comments

How do i compile the example?
from rust i have run
"cargo build"
then
"rustc examples/window.rc"
and i get

error: environment variable CARGO_MANIFEST_DIR not defined at compile time
--> examples/window.rs:90:28
|
90 | let path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/data/icon.png");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: Cargo sets build script variables at run time. Use std::env::var("CARGO_MANIFEST_DIR") instead
= note: this error originates in the macro env (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0432]: unresolved import cursor_icon
--> examples/window.rs:11:5
|
11 | use cursor_icon::CursorIcon;
| ^^^^^^^^^^^ maybe a missing crate cursor_icon?
|
= help: consider adding extern crate cursor_icon to use the cursor_icon crate

error[E0432]: unresolved import rwh_05
--> examples/window.rs:13:5
|
13 | use rwh_05::HasRawDisplayHandle;
| ^^^^^^ maybe a missing crate rwh_05?
|
= help: consider adding extern crate rwh_05 to use the rwh_05 crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:17:5
|
17 | use winit::application::ApplicationHandler;
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:18:5
|
18 | use winit::dpi::{LogicalSize, PhysicalPosition, PhysicalSize};
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:19:5
|
19 | use winit::event::{DeviceEvent, DeviceId, Ime, WindowEvent};
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:20:5
|
20 | use winit::event::{MouseButton, MouseScrollDelta};
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:21:5
|
21 | use winit::event_loop::{ActiveEventLoop, EventLoop};
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:22:5
|
22 | use winit::keyboard::{Key, ModifiersState};
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:23:5
|
23 | use winit::window::{
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0433]: failed to resolve: maybe a missing crate winit?
--> examples/window.rs:27:5
|
27 | use winit::window::{Window, WindowId};
| ^^^^^ maybe a missing crate winit?
|
= help: consider adding extern crate winit to use the winit crate

error[E0432]: unresolved import softbuffer
--> examples/window.rs:15:5
|
15 | use softbuffer::{Context, Surface};
| ^^^^^^^^^^ maybe a missing crate softbuffer?
|
= help: consider adding extern crate softbuffer to use the softbuffer crate

error[E0433]: failed to resolve: use of undeclared crate or module image
--> examples/window.rs:858:15
|
858 | let img = image::load_from_memory(bytes).unwrap().to_rgba8();
| ^^^^^ use of undeclared crate or module image

error[E0433]: failed to resolve: use of undeclared crate or module image
--> examples/window.rs:867:21
|
867 | let image = image::open(path)
| ^^^^^ use of undeclared crate or module image

error: aborting due to 14 previous errors

Some errors have detailed explanations: E0432, E0433.
For more information about an error, try rustc --explain E0432.

cargo run --example window.

In general, Winit is probably a bad place to start out, since it doesn't do any of the drawing that you likely want to do with your window. I'd recommend something like egui (for GUI programs) or bevy (for games) instead.