By default graphics.h library doesn’t include in CodeBlocks software. You can run graphics program by setup your CodeBlocks software like as below.
Step 1: At first download this. Click Here
Step 2: Now extract the downloaded zip file and copy the graphics.h and winbgim.h files and paste these files into your CodeBlocks compiler’s include folder. Copy the libbgi.a file and paste it into the lib folder.
include folder path: C:\Program Files\CodeBlocks\MinGW\include
lib folder path: C:\Program Files\CodeBlocks\MinGW\lib
Step 3: Now open the CodeBlocks software and go to the settings menu to compiler and select Linker setting. Add libbgi.a file by clicking add button and paste the code in the sidebox (Other linker options)
-lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
Step 4: Now save the settings by clicking ok button. Restart CodeBlocks software and run your program.
1. Your program should be c++ (.cpp) extension
2. If you get any error please replace the code of line no 302 in graphics.h file with
int left=0, int top=0, int right=INT_MAX, int bottom=INT_MAX,