Giter Site home page Giter Site logo

rust-sdl2_image's Introduction

Rust-SDL2_image

Rust bindings for SDL2_image

NOTE: The 1.0.0 and 1.1.0 version of this crate are yanked because of #65! We are now using same x.y._ version number as sdl2. See sdl2_image/0.25.0.

Overview

Rust-SDL2_image is a library for talking to the new SDL2_image library from Rust.

Rust-SDL2_image uses the MIT license.

Requirements

Installation

If you're using Cargo to manage your project, enter the following into your Cargo.toml file:

[dependencies]
sdl2 = "0.25.0"
sdl2_image = "0.25.0"

Or, to reference this repository directly:

[dependencies.sdl2_image]
git = "https://github.com/xsleonard/rust-sdl2_image"

Otherwise, clone this repo and run:

cargo build

If you're not using Cargo, you can compile manually:

git clone https://github.com/xsleonard/rust-sdl2_image
cd rust-sdl2_image
rustc src/sdl2_image/lib.rs
# OR if you are using the mac framework version
rustc --cfg mac_framework src/sdl2_image/lib.rs

Demo

You'll find included with the library a simple demo that loads and displays a given image :

cargo run /path/to/some/image.(jpg|png)

Or:

rustc -L. src/demo/main.rs -o demo
./demo image.(png|jpg)

rust-sdl2_image's People

Contributors

andelf avatar angrylawyer avatar azmr avatar baskerville avatar benjaminmalley avatar bitonic avatar cobrand avatar crumblingstatue avatar deadacute avatar jaburns avatar jiangyang avatar jubjub avatar machinetech avatar pinumbernumber avatar porglezomp avatar sbidin avatar sp0 avatar sunaurus avatar ttdonovan avatar wdv4758h avatar xsleonard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rust-sdl2_image's Issues

Update the version on crates.io

When I use

[dependencies]
sld2_image = "0.2.1"

The last version I saw on crates.io, downloads code from 2 months ago, which tries to link to sld2-sys 0.2 while sdl2 is linking to 0.4. Hence I am getting this error:

native library `SDL2` is being linked to by more than one package, and can only be linked to by one package

  sdl2-sys v0.2.2
  sdl2-sys v0.4.0

The quick fix was to use the following config:

[dependencies.sld2_image]
git = "https://github.com/xsleonard/rust-sdl2_image.git"

I don't know how exactly you deploy new versions to crates.io. I assume bumping the version with 1 does it automatically? I can submit a pull request if somebody confirms that this would fix the issue?

issue w/ linking/ cfg attribute OS detection on win7

I'm trying to build rust-sdl2_image and getting a weird build error:

   Compiling sdl2_image v0.0.1 (file:///C:/Users/jeff/src/rust-sdl2_image)
error: linking with `gcc` failed: exit code: 1
note: gcc '-m32' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib' '-o' 'C:\Users\jeff\src\rust-sdl2_i
mage\target\sdl2_image-2bba0ecf98a9b130.dll' 'C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o' '-
Wl,--whole-archive' '-lmorestack' '-Wl,--no-whole-archive' 'C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf
98a9b130.metadata.o' '-fno-lto' '-fno-use-linker-plugin' '-shared-libgcc' '-Wl,--enable-long-section-names' '-Wl,--nxcom
pat' '-Wl,--large-address-aware' 'C:\Users\jeff\src\rust-sdl2_image\target\deps\libsdl2-6a34150087b673a0.rlib' '-L' 'C:\
Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib' '-ldebug-4e7c5e5c' '-L' 'C:\Program Files (x86)\Rust\bin\rust
lib\i686-w64-mingw32\lib' '-lstd-4e7c5e5c' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib' '-lsync-4
e7c5e5c' '-L' 'C:\Program Files (x86)\Rust\bin\rustlib\i686-w64-mingw32\lib' '-lrustrt-4e7c5e5c' '-L' 'C:\Users\jeff\src
\rust-sdl2_image\target' '-L' 'C:\Users\jeff\src\rust-sdl2_image\target\deps' '-L' 'C:\Users\jeff\src\rust-sdl2_image\.r
ust' '-L' 'C:\Users\jeff\src\rust-sdl2_image' '-Wl,--whole-archive' '-Wl,-Bstatic' '-Wl,--no-whole-archive' '-Wl,-Bdynam
ic' '-lSDL2' '-shared' '-lcompiler-rt'
note: C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image19Surface.LoadS
urface9from_fileE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:72: undefined reference to `IMG_Load'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image19Surface.LoadSurface
14from_xpm_arrayE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:84: undefined reference to `IMG_ReadXPMFromArray'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image19Surface.SaveSurface
4saveE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:99: undefined reference to `IMG_SavePNG'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image19Surface.SaveSurface
7save_rwE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:111: undefined reference to `IMG_SavePNG_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image4initE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:146: undefined reference to `IMG_Init'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image4quitE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:153: undefined reference to `IMG_Quit'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image18get_linked_versionE
':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:159: undefined reference to `IMG_Linked_Version'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops4lo
adE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:213: undefined reference to `IMG_Load_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops10l
oad_typedE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:219: undefined reference to `IMG_LoadTyped_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_curE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:225: undefined reference to `IMG_LoadCUR_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_icoE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:229: undefined reference to `IMG_LoadICO_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_bmpE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:233: undefined reference to `IMG_LoadBMP_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_pnmE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:237: undefined reference to `IMG_LoadPNM_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_xpmE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:241: undefined reference to `IMG_LoadXPM_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_xcfE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:245: undefined reference to `IMG_LoadXCF_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_pcxE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:249: undefined reference to `IMG_LoadPCX_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_gifE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:253: undefined reference to `IMG_LoadGIF_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_jpgE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:257: undefined reference to `IMG_LoadJPG_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_tifE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:261: undefined reference to `IMG_LoadTIF_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_pngE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:265: undefined reference to `IMG_LoadPNG_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_tgaE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:269: undefined reference to `IMG_LoadTGA_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops8lo
ad_lbmE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:273: undefined reference to `IMG_LoadLBM_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops7lo
ad_xvE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:277: undefined reference to `IMG_LoadXV_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops9lo
ad_webpE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:281: undefined reference to `IMG_LoadWEBP_RW'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_curE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:286: undefined reference to `IMG_isCUR'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_icoE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:289: undefined reference to `IMG_isICO'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_bmpE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:292: undefined reference to `IMG_isBMP'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_pnmE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:295: undefined reference to `IMG_isPNM'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_xpmE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:298: undefined reference to `IMG_isXPM'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_xcfE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:301: undefined reference to `IMG_isXCF'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_pcxE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:304: undefined reference to `IMG_isPCX'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_gifE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:307: undefined reference to `IMG_isGIF'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_jpgE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:310: undefined reference to `IMG_isJPG'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_tifE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:313: undefined reference to `IMG_isTIF'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_pngE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:316: undefined reference to `IMG_isPNG'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops6is
_lbmE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:319: undefined reference to `IMG_isLBM'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops5is
_xvE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:322: undefined reference to `IMG_isXV'
C:\Users\jeff\src\rust-sdl2_image\target\sdl2_image-2bba0ecf98a9b130.o: In function `ZN10sdl2_image16RWops.ImageRWops7is
_webpE':
C:\Users\jeff\src\rust-sdl2_image/src\sdl2_image/lib.rs:325: undefined reference to `IMG_isWEBP'

error: aborting due to previous error
Could not compile `sdl2_image`.

I was able to get it to work, by modifying lib.rs like so in my local repo:

#[cfg(target_os="win32")]
#[cfg(target_os="linux")]
#[cfg(target_os="freebsd")]
mod others {
    #[link(name="SDL2_image")]
    extern {}
}
// this, the unconditional link.. so it seems like the target_os="win32" attribute isn't working?
#[link(name="SDL2_image")]
extern {}

I was thinking maybe its due to how the chunk of cfg blocks are arranged.. I know there're some warnings about this in the compiler:

   Compiling sdl2_image v0.0.1 (file:///C:/Users/jeff/src/rust-sdl2_image)
src\sdl2_image\lib.rs:36:1: 36:26 warning: The semantics of multiple `#[cfg(..)]` attributes on same item are changing f
rom the union of the cfgs to the intersection of the cfgs. Change `#[cfg(a)] #[cfg(b)]` to `#[cfg(any(a, b))]`.
src\sdl2_image\lib.rs:36 #[cfg(target_os="linux")]
                         ^~~~~~~~~~~~~~~~~~~~~~~~~
src\sdl2_image\lib.rs:37:1: 37:28 warning: The semantics of multiple `#[cfg(..)]` attributes on same item are changing f
rom the union of the cfgs to the intersection of the cfgs. Change `#[cfg(a)] #[cfg(b)]` to `#[cfg(any(a, b))]`.
src\sdl2_image\lib.rs:37 #[cfg(target_os="freebsd")]
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

I tried restructuring it like so:

#[cfg(any(target_os="win32", target_os="linux", target_os="freebsd"))]
mod others {
    #[link(name="SDL2_image")]
    extern {}
}

Without any luck.

Anywho, as I said.. I was able to work around it, but it's pretty awkward/annoying to deal with and the workaround isn't really something I can make a PR with.. so yeah. Any thoughts are welcome.

undefined macro 'bitflags!'

See: Rust-SDL2/rust-sdl2#281

me@pc:~/rust-sdl2_image$ rustc src/sdl2_image/lib.rs 
src/sdl2_image/lib.rs:44:1: 44:9 error: macro undefined: 'bitflags!'
src/sdl2_image/lib.rs:44 bitflags! {
                         ^~~~~~~~
error: aborting due to previous error

Sorry if this bug has been mentioned before; I think it's because I'm on the newest Rust version.

Edit: bug persists after modifying Cargo.toml:

[dependencies.sdl2]
sdl2 = "^0"
bitflags = "0.1"

Push 0.19.0 to crates.io with the updated dependencies

The current valid version on crates.io (0.18) has a dependency on an outdated version of sdl2-sys (0.8.1), which results in a dependency error when using other SDL libraries.

It looks like the version here on github has the correct dependencies set, so the only required change should be bumping the version in the cargofile :).

The dependency can be seen here.

For reference, the error I get is this:

error: native library `SDL2` is being linked to by more than one version of the same package, but it can only be linked once; try updating or pinning your dependencies to ensure that this package only shows up once

  sdl2-sys v0.19.0
  sdl2-sys v0.8.1

Repo as crate resource not compatible if sdl2 does the same

Beyond the compatibility difference between this package and more recent sdl2 crate releases, as mentioned in #50, the scenario of repo as crate source conflicts with sdl2 repo as a crate resource

I have found that when using the Rust-SDL2 repo as the crate source with

[dependencies.sdl2]
git = "https://github.com/AngryLawyer/rust-sdl2"

[dependencies.sdl2_image]
git = "https://github.com/xsleonard/rust-sdl2_image"

Has an issue with sdl2-sys since the source is from the same repo but this crate doesn't specify to use that repo source.

error: native library `SDL2` is being linked to by more than one package, and can only be linked to by one package

sdl2-sys v0.8.1 (https://github.com/AngryLawyer/rust-sdl2#217d55f8)
sdl2-sys v0.8.1

So it would seem that this crate assume when using Github as a source that the other crate is a pure crate grab of sdl2 and not their Github repo.

Let me know if this is an issue that can be amended via your Cargo.toml file or if I need to open an issue with that crate management repo for Cargo.

No method named `load_texture` found for type `sdl2::render::Renderer<'_>` in the current scope

I'm doing exactly like this:

let mut sdl_context = sdl2::init().unwrap();
let mut video = sdl_context.video().unwrap();
sdl2_image::init(INIT_PNG | INIT_JPG);
let window  = video.window("Test", 1280, 800).position_centered().opengl().build().unwrap();

let mut renderer = window.renderer().accelerated().build().unwrap();
let mut texture = renderer.load_texture(&Path::new("res/background.png")).unwrap();

And compiler gives me this:
src\main.rs:26:29: 26:75 error: no method named load_texture found for type sdl2::render::Renderer<'_> in the current scope
src\main.rs:26 let mut texture = renderer.load_texture(&Path::new("res/background.png")).unwrap();

Cargo Compiling Issue

Hey there,

I'm trying to compile the library on a Mac using cargo and getting the following compile issue:

Compiling sdl2_image v0.0.1-alpha.1 (file:///Users/sleroux/development/personal/rust-sdl2_image)
src/sdl2_image/lib.rs:129:25: 129:36 error: wrong number of type arguments: expected 0, found 1
src/sdl2_image/lib.rs:129 impl<T> LoadTexture for Renderer<T> {
                                                  ^~~~~~~~~~~
Could not compile `sdl2_image`.

Any ideas what could be going on?

Thanks!

Use rust-sdl2 0.5

Hi!

I've upgraded to rust-sdl2 0.5 in my free-time project/tests sandbox and changed the version of rust-sdl2 which rust-sdl2_image depends on in a fork of mine. Turns out it compiles as usual and I haven't had any problem yet. One only needs to change a bit the demo to get it to compile, too, so I included that in my commit.

It is to be noted that I also incremented the version number in Cargo.toml, considering changing dependencies seemed worth it.

I wondered about whether you would like to update the master branch.

Bump version number after push to crates.io instead of before?

Hi.
From http://doc.crates.io/crates-io.html:

"Take care when publishing a crate, because a publish is permanent. The version can never be overwritten, and the code cannot be deleted."

Currently for example, we have crate sdl2_image version 0.2.3 referencing sdl2 v 0.5.0, but the head of master (also at version 0.2.3) referencing sdl2 v 0.6.0. That would mean that a build against master would result in a library that is different from the one on crates.io (but with the same version number). I wonder if it would make sense to leave the version number for master one ahead of whatever has been published to crates.io? The lack of a published library would indicate it is still a work in progress. Once we are ready, then publish the new version to crates.io and afterwards bump the version number.

Package version is 1.x, even though API is *not* stable

In #60, the version was bumped to 1.0.0. This was a mistake, as our API is still unstable. At the very least, we depend on an unstable sdl2 crate, so every time we update our sdl2 dependency, it's a breaking change.

This means that we would have to increment the major version (i.e. 2.0.0, 3.0.0, ...) after every sdl2 upgrade.

I'm not sure if this can be fixed (either by yanking, or by special request, deleting for good our 1.x versions from crates.io), or if we are stuck having to upgrade the major version every time we make a breaking change.

Broken crate using rust 1.6

Due to this issue the crate no longer compiles:

Compiling sdl2_image v0.6.0
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:73:37: 73:95 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:73             let raw = ffi::IMG_Load(CString::new(filename.to_str().unwrap()).unwrap().as_ptr());
                                                                                                                                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:73:37: 73:95 help: run `rustc --explain E0308` to see a detailed explanation
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:99:55: 99:113 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:99             let status = ffi::IMG_SavePNG(self.raw(), CString::new(filename.to_str().unwrap()).unwrap().as_ptr());
                                                                                                                                                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:99:55: 99:113 help: run `rustc --explain E0308` to see a detailed explanation
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:131:56: 131:114 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:131             let raw = ffi::IMG_LoadTexture(self.raw(), CString::new(filename.to_str().unwrap()).unwrap().as_ptr());
                                                                                                                                                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:131:56: 131:114 help: run `rustc --explain E0308` to see a detailed explanation
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:218:50: 218:98 error: mismatched types:
 expected `*const i8`,
    found `*const u8`
(expected i8,
    found u8) [E0308]
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:218             ffi::IMG_LoadTyped_RW(self.raw(), 0, CString::new(_type.as_bytes()).unwrap().as_ptr())
                                                                                                                                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/odroid/.cargo/registry/src/github.com-48ad6e4054423464/sdl2_image-0.6.0/src/sdl2_image/lib.rs:218:50: 218:98 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to 4 previous errors

A mechanical cast as *const _ seems to be enough of a fix in most cases.
Rust 1.5 is still fine.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.