Reputation: 9
VS Code keeps displaying an error: fatal error: SDL2/SDL_image.h: No such file or directory
This is my code:
#include <iostream>
#include <SDL2/SDL.h>
const int WIDTH = 800, HEIGHT = 600;
int main( int argc, char *argv[] )
{
SDL_Init( SDL_INIT_EVERYTHING );
SDL_Window *window = SDL_CreateWindow( "Hello SDL WORLD", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WIDTH, HEIGHT, SDL_WINDOW_ALLOW_HIGHDPI );
if ( NULL == window )
{
std::cout << "Could not create window: " << SDL_GetError( ) << std::endl;
return 1;
}
SDL_Event windowEvent;
while ( true )
{
if ( SDL_PollEvent( &windowEvent ) )
{
if ( SDL_QUIT == windowEvent.type )
{ break; }
}
}
SDL_DestroyWindow( window );
SDL_Quit( );
return EXIT_SUCCESS;
}
HOWEVER, if I use makefile, instead of using the compile button it magically works...
I want to use Debbuger, however I'm unable to do so due to this error
Upvotes: 0
Views: 44
Reputation: 11
The reason MakeFile build works is because include paths and other info is set correctly, but vscode doesn't know about that.
You can use the MakeFile Tools extension. It provides info from MakeFile directly to vscode. This allows vscode in intellisense, compilation, debugging and lot more.
You will also find info on how to setup debugging in the Getting Started section.
Upvotes: 1