You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Cannot initialize sdl2 from the main function #224
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.
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
Just vague recollections of using SDL2, but the C API used to do some funky things with redefining main to SDL_Main or something like that - I wonder if the Android backed for SDL2 requires you to jump through some special main function wrapper they have?
Forgive me for asking though; is the sdl2 crate a sys wrapper around the SDL2 C library? If so I can't help but guess you might be unintentionally adding quite a bit more complexity to the system than by setting up the SDL main loop via a C main function using the original android_native_app_glue.c that comes with the NDK - but just a thought without any context.
Activity
rib commentedon May 23, 2022
Just vague recollections of using SDL2, but the C API used to do some funky things with redefining
maintoSDL_Mainor something like that - I wonder if the Android backed for SDL2 requires you to jump through some special main function wrapper they have?Forgive me for asking though; is the sdl2 crate a sys wrapper around the SDL2 C library? If so I can't help but guess you might be unintentionally adding quite a bit more complexity to the system than by setting up the SDL main loop via a C main function using the original
android_native_app_glue.cthat comes with the NDK - but just a thought without any context.