---
name: "SDL_Init"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_Init"
---

# SDL\_Init(3)

Initialize the SDL library.

## NAME

SDL\_Init - Initialize the SDL library.

## HEADER FILE

Defined in SDL3/SDL\_init.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**bool SDL\_Init(SDL\_InitFlags flags);**

## DESCRIPTION

**SDL\_Init** () simply forwards to calling

**SDL\_InitSubSystem** (). Therefore, the two may be used interchangeably. Though for readability of your code

**SDL\_InitSubSystem** () might be preferred.

The file I/O (for example:  **SDL\_IOFromFile** ) and threading ( **SDL\_CreateThread** ) subsystems are initialized by default. Message boxes ( **SDL\_ShowSimpleMessageBox** ) also attempt to work without initializing the video subsystem, in hopes of being useful in showing an error dialog when  **SDL\_Init**\
  fails. You must specifically initialize other subsystems if you use them in your application.

Logging (such as  **SDL\_Log** ) works without initialization, too. **flags** may be any of the following OR'd together:

•  **SDL\_INIT\_AUDIO** : audio subsystem; automatically\
   initializes the events subsystem

•  **SDL\_INIT\_VIDEO** : video subsystem; automatically\
   initializes the events subsystem, should be initialized on the main\
   thread.

•  **SDL\_INIT\_JOYSTICK** : joystick subsystem;\
   automatically initializes the events subsystem

•  **SDL\_INIT\_HAPTIC** : haptic (force feedback) subsystem

•  **SDL\_INIT\_GAMEPAD** : gamepad subsystem; automatically\
   initializes the joystick subsystem

•  **SDL\_INIT\_EVENTS** : events subsystem

•  **SDL\_INIT\_SENSOR** : sensor subsystem; automatically\
   initializes the events subsystem

•  **SDL\_INIT\_CAMERA** : camera subsystem; automatically\
   initializes the events subsystem

Subsystem initialization is ref-counted, you must call

**SDL\_QuitSubSystem** () for each

**SDL\_InitSubSystem** () to correctly shutdown a subsystem manually (or call  **SDL\_Quit** () to force shutdown). If a subsystem is already loaded then this call will increase the ref-count and return.

Consider reporting some basic metadata about your application before calling  **SDL\_Init** , using either

**SDL\_SetAppMetadata** () or

**SDL\_SetAppMetadataProperty** ().

## FUNCTION PARAMETERS

- *flags*

  subsystem initialization flags.

## RETURN VALUE

Returns true on success or false on failure; call

**SDL\_GetError** () for more information.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_SetAppMetadata**(3)](/SDL_SetAppMetadata/3.md), **•**(3), [**SDL\_SetAppMetadataProperty**(3)](/SDL_SetAppMetadataProperty/3.md), **•**(3), [**SDL\_InitSubSystem**(3)](/SDL_InitSubSystem/3.md), **•**(3), [**SDL\_Quit**(3)](/SDL_Quit/3.md), **•**(3), [**SDL\_SetMainReady**(3)](/SDL_SetMainReady/3.md), **•**(3), [**SDL\_WasInit**(3)](/SDL_WasInit/3.md)
