sdl2-config - script to get information about the installed version of SDL
Contents
Description
sdl2-config is a tool that is used to configure and determine the compiler and linker flags that should
be used to compile and link programs, libraries, and plugins that use SDL. It is also used internally by
the m4 macros that are included with SDL.
In new code, consider using pkg-config(1) or pkgconf(1) instead of sdl2-config. To support cross-
compiling, if the environment variable PKG_CONFIG is set, its value should be used instead of the literal
name pkg-config or pkgconf.
In Autotools build systems, the preferred way to detect SDL is with the PKG_CHECK_MODULES([SDL],[sdl2])
macro invocation from pkg.m4(7).
In Meson build systems, the preferred way to detect SDL is with Meson's usual dependency('sdl2') function
call.
In CMake build systems, the preferred way to detect SDL is to use find_package(SDL2CONFIG) and
optionally find_package(SDL2CONFIGCOMPONENTSSDL2main), then link to SDL2::SDL2 and optionally
SDL2::SDL2main.
Examples
gcc -o main.o $(sdl2-config --cflags) main.c
is how you might use sdl2-config to compile a C source file for an executable program.
gcc -o my_app $(sdl2-config --libs) main.o util.o
is how you might use sdl2-config to link compiled objects into an executable program.
Name
sdl2-config - script to get information about the installed version of SDL
Options
--cflags
Print the compiler flags that are necessary to compile a program or library that uses SDL.
The pkg-config equivalent is ${PKG_CONFIG:-pkg-config}--cflagssdl2.
--exec-prefix[=DIR]
If DIR is not specified, print the exec prefix of the current SDL installation. The pkg-config
equivalent is ${PKG_CONFIG:-pkg-config}--variable=exec_prefixsdl2.
If DIR is specified, use it instead of the installation exec prefix that SDL was built with when
computing the output for the --cflags, --libs and --static-libs options. This option must be
specified before any of the options --cflags, --libs and --static-libs. The pkg-config equivalent
is ${PKG_CONFIG:-pkg-config}--define-variable=exec_prefix=DIR [--cflags|--libs|...] sdl2.
--libs Print the linker flags that are necessary to link a program that uses SDL.
The pkg-config equivalent is ${PKG_CONFIG:-pkg-config}--libssdl2.
--static-libs
Print the linker flags that are necessary to statically link a program that uses SDL.
The pkg-config equivalent is ${PKG_CONFIG:-pkg-config}--static--libssdl2.
--prefix[=DIR]
If DIR is not specified, print the prefix of the current SDL installation. The pkg-config
equivalent is ${PKG_CONFIG:-pkg-config}--variable=prefixsdl2.
If DIR is specified, use it instead of the installation prefix that SDL was built with when
computing the output for the --cflags, --libs and --static-libs options. This option is also used
for the exec prefix if --exec-prefix was not specified. This option must be specified before any
of the options --cflags, --libs and --static-libs. The pkg-config equivalent is
${PKG_CONFIG:-pkg-config}--define-variable=prefix=DIR [--cflags|--libs|...] sdl2.
--version
Prints the currently installed version of SDL on standard output. The pkg-config equivalent is
${PKG_CONFIG:-pkg-config}--modversionsdl2.
See Also
pkgconf(1), pkg-config(1), pc(5), pkg.m4(7)
Synopsis
sdl2-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--cflags] [--libs] [--static-libs]
