Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

383
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda