A slight problem with SDL2 and Rust

VS Code Rust SDL Copikle problemThis is on Ubuntu 24.04 LTS. I’ve installed the dev versions of SDL2, including images and TTF.  You can read how to install them in this tutorial.

Once that’s done you add them to the rust project with commands like this

cargo add sdl2

You can see these instruction in the relevant crates pages. For instance SDL2 crate, SDL2 Image and SDL2 TTF.

So far so good. The cargo add added the crates into cargo.toml as expected but when I compiled it. Not a compile error as such but a version of dll hell.

The text in that image says:

Updating crates.io index
error: failed to select a version for `sdl2-sys`.
... required by package `sdl2_image v0.25.0`
... which satisfies dependency `sdl2_image = "^0.25.0"` of package `sdl1 v0.1.0 (/home/david/rust/sdl1)`
versions that meet the requirements `^0.25.0` are: 0.25.0

the package `sdl2-sys` links to the native library `SDL2`, but it conflicts with a previous package which links to `SDL2` as well:
package `sdl2-sys v0.37.0`
... which satisfies dependency `sdl2-sys = "^0.37.0"` of package `sdl1 v0.1.0 (/home/david/rust/sdl1)`
Only one package in the dependency graph may specify the same links value. This helps ensure that only one copy of a native library is linked in the final binary. Try to adjust your dependencies so that only one package uses the `links = "SDL2"` value. For more information, see https://doc.rust-lang.org/cargo/reference/resolver.html#links.

failed to select a version for `sdl2-sys` which could resolve this conflict

The problem appears to be a clash between sdl-sys and sdl2-ttf or sdl2-image. If anyone knows a fix…

 

(Visited 85 times, 1 visits today)