How to enable graphics.h in CodeBlocks

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 pathC:\Program Files\CodeBlocks\MinGW\include

lib folder pathC:\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

Linker setup for graphics.h

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,

Share on :

One Response to “How to enable graphics.h in CodeBlocks”

  1. leo minhaz says:

    thank u so so much. it eventually helped me a lot to enable graphics in my codeblocks.

Leave a Reply

four × = 24