Home > OS >  SDL2 begin_code.h file not found
SDL2 begin_code.h file not found

Time:02-24

I just started exploring with SDL 2 recently and downloaded libstl2-dev on Linux (I'm using Mint, if that matters).

However, when I include the header #include <SDL2/SDL.h>, vim keeps telling me an error In included file: 'begin_code.h' file not [clang: pp_file_not_found], note that I'm using coc with vim.

I've done some research but I couldn't fix the problem. In particular, I noticed this post, but the question was on VS code and I'm not sure how to apply this to vim.

Below is a part of my code.

#include "board.h"
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_timer.h>

void Board::help_init();

CodePudding user response:

Most Linux distros SDL development packages should include usable pkg-config tooling that will allow you to query include and library locations/names that you can pass to the compiler:

g   main.cpp `pkg-config --cflags --libs sdl2`

(Or you can use $() for subcommand capture instead of backticks)

On this Debian box pkg-config returns these paths/flags:

$ pkg-config --cflags sdl2
-D_REENTRANT -I/usr/include/SDL2

$ pkg-config --libs sdl2
-lSDL2

Note that -I path means you should #include <SDL.h> & friends, not #include <SDL2/SDL.h>:

// wrong
//#include <SDL2/SDL.h>
//#include <SDL2/SDL_image.h>
//#include <SDL2/SDL_timer.h>
// right
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_timer.h>

Though for whatever reason the Debian packaging for SDL add-on libraries like SDL-image have capitalized pkg-config package names:

g   main.cpp `pkg-config --cflags --libs sdl2 SDL2_image`

CodePudding user response:

Did you link SDL library? I don't know which build system you use, if you don't link SDL library, you must link the library and rebuild it.

  • Related