I started using SDL2 library with Code::Blocks IDE under windows. I downloaded the binary files for mingw64 which I use to compile, and I Included the search directories in the Compiler and Linker options.
My simple program would not compile:
//Using SDL and standard IO
#include <SDL.h>
#include <stdio.h>
int main( int argc, char* args[] )
{
//Initialize SDL
SDL_Init( SDL_INIT_VIDEO );
//Quit SDL subsystems
SDL_Quit();
return 0;
}
Returning me the errors:
main.c:13: undefined reference to `SDL_Init'
main.c:16: undefined reference to `SDL_Quit'
undefined reference to `WinMain'
Turns out I missed to use the linker options:
-lmingw32 -lSDL2main -lSDL2
I was not able to find out that I missed the linker options, without the help of this tutorial and other online forums. I was looking in the official documentation and wiki of the SDL and this is not mentioned anywhere.
Since this happens often to me (I go and try to use a library, the official documentation does not mention the important steps to compile the library. Sometimes it doesnt mention the files you need to include, others it does not mention the linker options one needs.). My question is:
How would someone using SDL library, find out they need to use these linker settings without the help of forums and tutorials? Could I found out from the errors it gave me upon compiling maybe?
I do not make the question general, I emphasize in this specific library, but the issue I have is general.