I'm trying to compile this code:
#include "SDL/SDL.h"
int main(void) {
SDL_Surface *Hello = NULL;
SDL_Surface *Screen = NULL;
SDL_Init( SDL_INIT_EVERYTHING );
return 0;
}
But it happens that the compiler says that:
undefined reference to SDL_Init
I dont know why this is happening. I'm using Debian Mint and Code::Blocks. Could you Help me?
Go to project and then build options and select your project name.
Now go to the
linker
setting and type the following lines in theOther Linker options
textbox:SDL
also requires command line arguments in the main function so you should changeto
Now compile your project and it should work.
It looks like you haven't got
-lSDL
on your link line.sdl-config
returns the compile and link flags for your installation of SDL.Assuming the program is
sdl.cpp
Should give you the correct flags.