This is always no_std
. To define the C types involved, the bindings use
winapi
on Windows and libc
elsewhere.
Currently only supports the desktop platforms: Windows, Mac, and Linux.
sdl2-sys
?Fair question. I'd say that between that crate and this crate there's two notable differences:
Debug
and
PartialEq
impls for all the types.const
values, instead of
Rust enum
types.If those don't sound like a good enough reason to switch to this crate, keep
using sdl2-sys
.
Before Building: Since this crate is about SDL2 bindings, it obviously
requires SDL2. You will need the latest stable version of SDL2 (currently
2.0.9
).
Building: This library uses
bindgen as a build-dependency
.
By default it will attempt to invoke the CLI version of the program, but if
you enable the use_bindgen_lib
feature then it will build bindgen
as a
library and use it that way. Either as a cli program or as a library,
bindgen
requires a working copy of clang
(3.9 or later) to be installed.
The bindgen
requirements
page has
instructions for installing clang for each major OS. Windows Users: after
installing LLVM you must manually make an environment variable for
LIBCLANG_PATH
pointing to the install directory that has libclang.dll
(eg:
D:\programs\LLVM\bin
)
static_link_sdl2_use_with_caution
feature if you would like to staticly link SDL2 instead of the normal
dynamic link.-fPIC
flag.LD_LIBRARY_PATH
list to be searched for the static lib files (which
should find SDL2 just fine).Running: Once you've compiled your program using this library, you'll need to have the SDL2 dynamic library somewhere that the OS can find for your program to run.
SDL2.dll
available. It's also in the lib directory of this
repository.LD_LIBRARY_PATH
to point to an appropriate directory.Shipping: When you're ready to send a program out the door, how should you package SDL2 along with your program? Well, it depends.
SDL2.dll
file along side
your program.exe
. DLL loading starts by checking the same directory as the
executable, so it's sure to find the correct DLL that way. If the user
really needs to they can replace the DLL later. Having one copy of
SDL2.dll
per program isn't a huge deal, it's only about 1.4 megabytes.This crate uses the Zlib license (the same license as SDL2 itself uses).