Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

380
Vistas
How do I use SDL2 in my programs correctly?

I want to make a game using SDL2, but I'm unable to compile and/or run my code, please help!

SDL2 is notoriously hard to set up, and it's often the first library aspiring game developers try to use.

This post is intended as a canonical duplicate for common problems with setting up SDL2.

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

On Mac this is what I follow for XCode (must install g++):

sdl linking:

g++ main.cpp -o main $(sdl2-config --cflags --libs)

XCODE project steps:

  1. open terminal app (macOS)

  2. BUILD SETTINGS (select 'all' and 'combined' search bar enter: "search")

  3. click on "header search paths(way right side click)

  4. add: /usr/local/include

  5. BUILD PHASES --> LINK BINARY LIBRARIES (click plus)

  6. type in SDL --> click "add other"

  7. press: command+SHIFT+g (to bring search bar)

  8. type in: usr/local/Cellar

  9. navigate to: SDL2 -->2.0.8 -->lib --> libSDL2-2.2.0.dylib (make sure not shortcut)

over 4 years ago · Santiago Trujillo Denunciar

0

A solution for Visual Studio:

Why not use a package manager? I use vcpkg, and it makes super easy to consume 3rd party libraries. Grab the vcpkg source, and extract it to a safe place, like C:/, then run its bootstrap script bootstrap-vcpkg.bat, this will generate vcpkg executable. Then run vcpkg integrate install to make libraries installed with vcpkg available in Visual Studio.

Search for the library you need:

vcpkg search sdl

imgui[sdl2-binding]                   Make available SDL2 binding
libwebp[vwebp-sdl]                    Build the vwebp viewer tool.
magnum[sdl2application]               Sdl2Application library
sdl1                 1.2.15#12        Simple DirectMedia Layer is a cross-platform development library designed to p...
sdl1-net             1.2.8-3          Networking library for SDL
sdl2                 2.0.12-1         Simple DirectMedia Layer is a cross-platform 
...

Install it with: vcpkg install sdl2.

Now you just need include SDL2 headers, and everything will work out of the box. The library will be linked automatically.

You can learn more about vcpkg here.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda