1

I have managed to compile this sample program that uses SDL

#include "SDL.h" 

int main(int argc, char *argv[])
{
  SDL_Init(SDL_INIT_VIDEO);

  SDL_Window *window = SDL_CreateWindow(
    "SDL2Test",
    SDL_WINDOWPOS_UNDEFINED,
    SDL_WINDOWPOS_UNDEFINED,
    640,
    480,
    0
  );

  SDL_Renderer *renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_SOFTWARE);
  SDL_SetRenderDrawColor(renderer, 0, 0, 0, SDL_ALPHA_OPAQUE);
  SDL_RenderClear(renderer);
  SDL_RenderPresent(renderer);

  SDL_Delay(3000);

  SDL_DestroyWindow(window);
  SDL_Quit();

  return 0;
}

using the following CMake file

cmake_minimum_required(VERSION 2.8)
project( project )

find_package(SDL2 REQUIRED)
include_directories(${SDL2_INCLUDE_DIRS})

add_executable( project sdl.cpp )
target_link_libraries( project ${SDL2_LIBRARIES})

but I have no way of determining where "SDL.h" is. locate SDL.h didn't work either. Is it somewhere hidden "behind the scenes" or I am doing some kind of typo error?

SDL2 was installed through sudo apt-get install libsdl2-dev

Tetix
  • 317
  • 2
  • 10
  • 1
    It depends on your distribution, but try `sudo updatedb` to update the locate db. – user1810087 Apr 30 '19 at 12:32
  • Wow, that worked... I didn't know I had to do that, neither what it does... Thanks a lot! – Tetix Apr 30 '19 at 12:36
  • 1
    Locate depends on a database which is updated from time to time by a daemon. If you just installed a new package, it probably need some time to update the database. But it depends on your distro and settings. https://en.wikipedia.org/wiki/Locate_(Unix). Or from manpage: [...] The system administrator can choose the file name of the default database, **the frequency with which the databases are updated**, and the directories for which they contain entries; see updatedb(1). [...] – user1810087 Apr 30 '19 at 12:39
  • 3
    Because this was tagged [tag:c++], here a C++ (`g++`) solution: add (temporarily) `-H` to the compile flags. This will let `g++` report any included files. (I searched for this knowing that VS has a similar option.) Found it here: [SO: How To Get g++ to list paths to all #included files](https://stackoverflow.com/a/20477307/7478597). (I could imagine that the amount of generated output might be a little bit scaring. Hence it might be worth to mention [`grep`](https://en.wikipedia.org/wiki/Grep) as well...) ;-) – Scheff's Cat Apr 30 '19 at 12:55
  • Since you appear to be using Debian or Ubuntu, `dpkg -L libsdl2-dev` will list all the files in that package. – jamieguinan Apr 30 '19 at 15:10

0 Answers0