Skip to content

Cannot initialize sdl2 from the main function #224

@seguidor777

Description

@seguidor777

I'm facing the following issue,

When I try to initialize sdl2 from my main function, the project compiles without errors.
But when I run it, I can see that it fails in the sdl2 init call.

lib.rs

#[cfg_attr(target_os = "android", ndk_glue::main(backtrace = "on"))]
fn main() {
    println!("Hello from Android!");
    let _ = sdl2::init().unwrap();
}

These are the entries that I'm seeing in logcat:

02-08 04:06:55.196 14840 14884 I RustStdoutStderr: Hello from Android!
02-08 04:06:55.196 14840 14884 I RustStdoutStderr: thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "Application didn't initialize properly, did you include SDL_main.h in the file containing your main() function?"', src/lib.rs:17:36
02-08 04:06:55.196 14840 14884 I RustStdoutStderr: stack backtrace:
02-08 04:06:55.202 14840 14884 I RustStdoutStderr: note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Please let me know if you need additional details. Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions