Use TDM-GCC compiler and it will be solved.
https://sourceforge.net/projects/tdm-gcc/files/TDM-GCC%204.9%20series/4.9.2-tdm-1%20DW2/
then use it as the compiler for the codeblocks or the IDE you're using, set load the winbglm files to the tdm-gcc under include for graphics.h and winbglm then for lib you paste libbgi.a and you will be good to go.