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

"bundled" feature compiles on Linux but resulting executable does not show window #1447

Open
pozix604 opened this issue Dec 11, 2024 · 4 comments

Comments

@pozix604
Copy link

On Debian 12, without libsdl2-dev installed, I have the following project. I compile with cargo b -vv (build.log) which succeeds, but when running the executable, nothing shows. Same if I add the static-link feature.

Cargo.toml:

[package]
name = "tsdl2"
version = "0.1.0"
edition = "2021"

[dependencies]
sdl2 = { version = "0.37.0", features = ["bundled"] }

main.rs:

use sdl2::pixels::Color;
use std::thread::sleep;
use std::time::Duration;

fn main() -> Result<(), String> {
    let window = sdl2::init()?
        .video()?
        .window("SDL Window", 256, 256)
        .position_centered()
        .opengl()
        .build()
        .map_err(|e| e.to_string())?;

    let mut renderer = window.into_canvas().build().map_err(|e| e.to_string())?;
    renderer.set_draw_color(Color::RGB(0, 255, 128));
    renderer.clear();
    renderer.present();

    sleep(Duration::new(2, 0));
    Ok(())
}

Removing the bundled feature, then sudo apt install libsdl2-dev, recompiling and re-runing works as expected.

@pozix604 pozix604 changed the title "bundled" feature compiles but does not work "bundled" feature compiles on Linux but resulting executable does not show window Dec 11, 2024
@Cobrand
Copy link
Member

Cobrand commented Jan 2, 2025

What are the logs when running from the command line? Surely there must be some kind of error if it cannot show the window.

@pozix604
Copy link
Author

pozix604 commented Jan 2, 2025

Surely there must be some kind of error if it cannot show the window.

No errors, warnings or other information shown.

@WoMspace
Copy link

I have the same issue. No window is made, and nothing is printed to the console. It works fine on macOS and Windows, but on linux the bundled feature transparently fails. I got the above sample working by installing the SDL2-devel package and disabling the bundled feature, as per pozix's original comment.
openSUSE Tumbleweed, Plasma 6 on Wayland, rustc 1.84.0, sdl2 crate 0.37.0

@Cobrand
Copy link
Member

Cobrand commented Jan 24, 2025

Maybe try using log::set_output_function and show everything in trace to see where the issue might come from? At this point we can only guess without logs.

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

No branches or pull requests

3 participants